* Remove _Test suffixes regarding issue #532
This commit is contained in:
Piotr Blachnio 2020-10-15 13:36:23 +02:00 коммит произвёл GitHub
Родитель 88b9dd367b
Коммит 8b0ba657c6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
82 изменённых файлов: 683 добавлений и 683 удалений

Просмотреть файл

@ -78,7 +78,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T101_StateFlip_Test \n",
"%kata T101_StateFlip \n",
"\n",
"operation StateFlip (q : Qubit) : Unit is Adj+Ctl {\n",
" // The Pauli X gate will change the |0⟩ state to the |1⟩ state and vice versa.\n",
@ -113,7 +113,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T102_BasisChange_Test \n",
"%kata T102_BasisChange \n",
"\n",
"operation BasisChange (q : Qubit) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -137,7 +137,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T103_SignFlip_Test \n",
"%kata T103_SignFlip \n",
"\n",
"operation SignFlip (q : Qubit) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -170,7 +170,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T104_AmplitudeChange_Test\n",
"%kata T104_AmplitudeChange\n",
"\n",
"operation AmplitudeChange (alpha : Double, q : Qubit) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -194,7 +194,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T105_PhaseFlip_Test\n",
"%kata T105_PhaseFlip\n",
"\n",
"operation PhaseFlip (q : Qubit) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -224,7 +224,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T106_PhaseChange_Test\n",
"%kata T106_PhaseChange\n",
"\n",
"operation PhaseChange (alpha : Double, q : Qubit) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -256,7 +256,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T107_GlobalPhaseChange_Test\n",
"%kata T107_GlobalPhaseChange\n",
"\n",
"operation GlobalPhaseChange (q : Qubit) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -280,7 +280,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T108_BellStateChange1_Test\n",
"%kata T108_BellStateChange1\n",
"\n",
"operation BellStateChange1 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -304,7 +304,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T109_BellStateChange2_Test\n",
"%kata T109_BellStateChange2\n",
"\n",
"operation BellStateChange2 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -335,7 +335,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T110_BellStateChange3_Test\n",
"%kata T110_BellStateChange3\n",
"\n",
"operation BellStateChange3 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -381,7 +381,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T201_TwoQubitGate1_Test\n",
"%kata T201_TwoQubitGate1\n",
"\n",
"operation TwoQubitGate1 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -409,7 +409,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T202_TwoQubitGate2_Test\n",
"%kata T202_TwoQubitGate2\n",
"\n",
"operation TwoQubitGate2 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -436,7 +436,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T203_TwoQubitGate3_Test\n",
"%kata T203_TwoQubitGate3\n",
"\n",
"operation TwoQubitGate3 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -461,7 +461,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T204_ToffoliGate_Test\n",
"%kata T204_ToffoliGate\n",
"\n",
"operation ToffoliGate (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -486,7 +486,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T205_FredkinGate_Test\n",
"%kata T205_FredkinGate\n",
"\n",
"operation FredkinGate (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",

Просмотреть файл

@ -49,7 +49,7 @@ namespace Quantum.Kata.BasicGates {
operation StateFlip (q : Qubit) : Unit is Adj+Ctl {
// The Pauli X gate will change the |0⟩ state to the |1⟩ state and vice versa.
// Type X(q);
// Then rebuild the project and rerun the tests - T11_StateFlip_Test should now pass!
// Then rebuild the project and rerun the tests - T11_StateFlip should now pass!
// ...
}

Просмотреть файл

@ -82,7 +82,7 @@ namespace Quantum.Kata.BasicGates {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T101_StateFlip_Test () : Unit {
operation T101_StateFlip () : Unit {
DumpDiffOnOneQubit(StateFlip, StateFlip_Reference);
AssertOperationsEqualReferenced(2, ArrayWrapperControlled(StateFlip, _),
ArrayWrapperControlled(StateFlip_Reference, _));
@ -91,7 +91,7 @@ namespace Quantum.Kata.BasicGates {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T102_BasisChange_Test () : Unit {
operation T102_BasisChange () : Unit {
DumpDiffOnOneQubit(BasisChange, BasisChange_Reference);
AssertOperationsEqualReferenced(2, ArrayWrapperControlled(BasisChange, _),
ArrayWrapperControlled(BasisChange_Reference, _));
@ -100,7 +100,7 @@ namespace Quantum.Kata.BasicGates {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T103_SignFlip_Test () : Unit {
operation T103_SignFlip () : Unit {
DumpDiffOnOneQubit(SignFlip, SignFlip_Reference);
AssertOperationsEqualReferenced(2, ArrayWrapperControlled(SignFlip, _),
ArrayWrapperControlled(SignFlip_Reference, _));
@ -109,7 +109,7 @@ namespace Quantum.Kata.BasicGates {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T104_AmplitudeChange_Test () : Unit {
operation T104_AmplitudeChange () : Unit {
// pick one rotation angle on which to show difference between solutions
let dumpAlpha = ((2.0 * PI()) * IntAsDouble(6)) / 36.0;
Message($"Applying amplitude change with alpha = {dumpAlpha}");
@ -125,7 +125,7 @@ namespace Quantum.Kata.BasicGates {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T105_PhaseFlip_Test () : Unit {
operation T105_PhaseFlip () : Unit {
DumpDiffOnOneQubit(PhaseFlip, PhaseFlip_Reference);
AssertOperationsEqualReferenced(2, ArrayWrapperControlled(PhaseFlip, _),
ArrayWrapperControlled(PhaseFlip_Reference, _));
@ -134,7 +134,7 @@ namespace Quantum.Kata.BasicGates {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T106_PhaseChange_Test () : Unit {
operation T106_PhaseChange () : Unit {
let dumpAlpha = ((2.0 * PI()) * IntAsDouble(10)) / 36.0;
Message($"Applying phase change with alpha = {dumpAlpha}");
DumpDiffOnOneQubit(PhaseChange(dumpAlpha,_), PhaseChange_Reference(dumpAlpha,_));
@ -155,7 +155,7 @@ namespace Quantum.Kata.BasicGates {
}
@Test("QuantumSimulator")
operation T107_GlobalPhaseChange_Test () : Unit {
operation T107_GlobalPhaseChange () : Unit {
// use the controlled version of unitaries for showing the difference, since it's hard to observe on non-controlled versions
Message("Showing effect of controlled-GlobalPhaseChange");
DumpDiff(2, StatePrepForControlled,
@ -214,7 +214,7 @@ namespace Quantum.Kata.BasicGates {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T108_BellStateChange1_Test () : Unit {
operation T108_BellStateChange1 () : Unit {
DumpDiff(2, StatePrep_BellState(_, 0), BellStateChange1, BellStateChange1_Reference);
VerifyBellStateConversion(BellStateChange1, 0, 1);
}
@ -222,7 +222,7 @@ namespace Quantum.Kata.BasicGates {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T109_BellStateChange2_Test () : Unit {
operation T109_BellStateChange2 () : Unit {
DumpDiff(2, StatePrep_BellState(_, 0), BellStateChange2, BellStateChange2_Reference);
VerifyBellStateConversion(BellStateChange2, 0, 2);
}
@ -230,7 +230,7 @@ namespace Quantum.Kata.BasicGates {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T110_BellStateChange3_Test () : Unit {
operation T110_BellStateChange3 () : Unit {
DumpDiff(2, StatePrep_BellState(_, 0), BellStateChange3, BellStateChange3_Reference);
Message("If the desired and the actual states match but the test doesn't pass, check whether your solution introduces a global phase; it shouldn't!");
VerifyBellStateConversion(BellStateChange3, 0, 3);
@ -243,7 +243,7 @@ namespace Quantum.Kata.BasicGates {
}
@Test("QuantumSimulator")
operation T201_TwoQubitGate1_Test () : Unit {
operation T201_TwoQubitGate1 () : Unit {
DumpDiff(2, StatePrepRy, TwoQubitGate1, TwoQubitGate1_Reference);
// Note that the way the problem is formulated, we can't just compare two unitaries,
@ -273,7 +273,7 @@ namespace Quantum.Kata.BasicGates {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T202_TwoQubitGate2_Test () : Unit {
operation T202_TwoQubitGate2 () : Unit {
DumpDiff(2, ApplyToEachCA(H, _), TwoQubitGate2, TwoQubitGate2_Reference);
using (qs = Qubit[2]) {
within {
@ -309,7 +309,7 @@ namespace Quantum.Kata.BasicGates {
}
@Test("QuantumSimulator")
operation T203_TwoQubitGate3_Test () : Unit {
operation T203_TwoQubitGate3 () : Unit {
DumpDiff(2, StatePrepMiscAmplitudes, TwoQubitGate3, TwoQubitGate3_Reference);
AssertOperationsEqualReferenced(2, SwapWrapper, TwoQubitGate3_Reference);
AssertOperationsEqualReferenced(2, TwoQubitGate3, TwoQubitGate3_Reference);
@ -318,7 +318,7 @@ namespace Quantum.Kata.BasicGates {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T204_ToffoliGate_Test () : Unit {
operation T204_ToffoliGate () : Unit {
DumpDiff(3, StatePrepMiscAmplitudes, ToffoliGate, ToffoliGate_Reference);
AssertOperationsEqualReferenced(3, ToffoliGate, ToffoliGate_Reference);
}
@ -326,7 +326,7 @@ namespace Quantum.Kata.BasicGates {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T205_FredkinGate_Test () : Unit {
operation T205_FredkinGate () : Unit {
DumpDiff(3, StatePrepMiscAmplitudes, FredkinGate, FredkinGate_Reference);
AssertOperationsEqualReferenced(3, FredkinGate, FredkinGate_Reference);
}

Просмотреть файл

@ -57,7 +57,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_WinCondition_Test \n",
"%kata T11_WinCondition \n",
"\n",
"function WinCondition (x : Bool, y : Bool, a : Bool, b : Bool) : Bool {\n",
" // ...\n",
@ -92,7 +92,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_ClassicalStrategy_Test \n",
"%kata T12_ClassicalStrategy \n",
"\n",
"operation AliceClassical (x : Bool) : Bool {\n",
" // ...\n",
@ -115,7 +115,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_ClassicalStrategy_Test \n",
"%kata T12_ClassicalStrategy \n",
"\n",
"operation BobClassical (y : Bool) : Bool {\n",
" // ...\n",
@ -158,7 +158,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_CreateEntangledPair_Test \n",
"%kata T21_CreateEntangledPair \n",
"\n",
"operation CreateEntangledPair (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -195,7 +195,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_AliceQuantum_Test \n",
"%kata T22_AliceQuantum \n",
"\n",
"operation AliceQuantum (bit : Bool, qubit : Qubit) : Bool {\n",
" // ...\n",
@ -237,7 +237,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T23_RotateBobQubit_Test \n",
"%kata T23_RotateBobQubit \n",
"\n",
"open Microsoft.Quantum.Math;\n",
"\n",
@ -276,7 +276,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T24_BobQuantum_Test \n",
"%kata T24_BobQuantum \n",
"\n",
"operation BobQuantum (bit : Bool, qubit : Qubit) : Bool {\n",
" // ...\n",
@ -312,7 +312,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T25_PlayQuantumCHSH_Test \n",
"%kata T25_PlayQuantumCHSH \n",
"\n",
"operation PlayQuantumCHSH (askAlice : (Qubit => Bool), askBob : (Qubit => Bool)): (Bool, Bool) {\n",
" // ...\n",

Просмотреть файл

@ -18,7 +18,7 @@ namespace Quantum.Kata.CHSHGame {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T11_WinCondition_Test () : Unit {
operation T11_WinCondition () : Unit {
for (i in 0..1 <<< 4 - 1) {
let bits = IntAsBoolArray(i, 4);
EqualityFactB(
@ -32,7 +32,7 @@ namespace Quantum.Kata.CHSHGame {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T12_ClassicalStrategy_Test () : Unit {
operation T12_ClassicalStrategy () : Unit {
mutable wins = 0;
for (i in 1..1000) {
let x = DrawRandomInt(0, 1) == 1 ? true | false;
@ -64,7 +64,7 @@ namespace Quantum.Kata.CHSHGame {
}
@Test("QuantumSimulator")
operation T21_CreateEntangledPair_Test () : Unit {
operation T21_CreateEntangledPair () : Unit {
// We only check for 2 qubits.
AssertEqualOnZeroState(2, CreateEntangledPair, CreateEntangledPair_Reference);
}
@ -72,7 +72,7 @@ namespace Quantum.Kata.CHSHGame {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T22_AliceQuantum_Test () : Unit {
operation T22_AliceQuantum () : Unit {
for (_ in 1 .. 4) {
// repeat 4 times since we are testing a measurement and wrong basis still might get
// the correct answer, reduces probability of false positives
@ -110,7 +110,7 @@ namespace Quantum.Kata.CHSHGame {
}
@Test("QuantumSimulator")
operation T23_RotateBobQubit_Test () : Unit {
operation T23_RotateBobQubit () : Unit {
AssertOperationsEqualReferenced(1, QubitToRegisterOperation(RotateBobQubit(true, _), _),
QubitToRegisterOperationA(Ry(-2.0 * PI() / 8.0, _), _));
AssertOperationsEqualReferenced(1, QubitToRegisterOperation(RotateBobQubit(false, _), _),
@ -120,7 +120,7 @@ namespace Quantum.Kata.CHSHGame {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T24_BobQuantum_Test () : Unit {
operation T24_BobQuantum () : Unit {
for (_ in 1 .. 4) {
// repeat 4 times since we are testing a measurement and wrong basis still might get
// the correct answer, reduces probability of false positives
@ -149,7 +149,7 @@ namespace Quantum.Kata.CHSHGame {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T25_PlayQuantumCHSH_Test () : Unit {
operation T25_PlayQuantumCHSH () : Unit {
mutable wins = 0;
for (i in 1..10000) {
let x = DrawRandomInt(0, 1) == 1 ? true | false;

Просмотреть файл

@ -56,7 +56,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_WinCondition_Test \n",
"%kata T11_WinCondition \n",
"\n",
"open Microsoft.Quantum.Logical;\n",
"\n",
@ -107,7 +107,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_ClassicalStrategy_Test \n",
"%kata T12_ClassicalStrategy \n",
"\n",
"operation AliceClassical (x : Bool) : Bool {\n",
" return true;\n",
@ -120,7 +120,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_ClassicalStrategy_Test \n",
"%kata T12_ClassicalStrategy \n",
"\n",
"operation BobClassical (y : Bool) : Bool {\n",
" // Alternatively, Alice and Bob could agree to always return FALSE to achieve the same 75% win chances.\n",
@ -172,7 +172,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_CreateEntangledPair_Test \n",
"%kata T21_CreateEntangledPair \n",
"\n",
"operation CreateEntangledPair (qs : Qubit[]) : Unit {\n",
" H(qs[0]);\n",
@ -241,7 +241,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_AliceQuantum_Test \n",
"%kata T22_AliceQuantum \n",
"\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
@ -299,7 +299,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T23_RotateBobQubit_Test \n",
"%kata T23_RotateBobQubit \n",
"\n",
"open Microsoft.Quantum.Math;\n",
"\n",
@ -355,7 +355,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T24_BobQuantum_Test \n",
"%kata T24_BobQuantum \n",
"\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
@ -407,7 +407,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T25_PlayQuantumCHSH_Test \n",
"%kata T25_PlayQuantumCHSH \n",
"\n",
"operation PlayQuantumCHSH (askAlice : (Qubit => Bool), askBob : (Qubit => Bool)): (Bool, Bool) {\n",
" using (bell = Qubit[2]) {\n",

Просмотреть файл

@ -59,7 +59,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_Oracle_Zero_Test \n",
"%kata T11_Oracle_Zero \n",
"\n",
"operation Oracle_Zero (x : Qubit[], y : Qubit) : Unit {\n",
" // Since f(x) = 0 for all values of x, |y ⊕ f(x)⟩ = |y⟩.\n",
@ -96,7 +96,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_Oracle_One_Test \n",
"%kata T12_Oracle_One \n",
"\n",
"operation Oracle_One (x : Qubit[], y : Qubit) : Unit {\n",
" // ...\n",
@ -123,7 +123,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T13_Oracle_Kth_Qubit_Test \n",
"%kata T13_Oracle_Kth_Qubit \n",
"\n",
"open Microsoft.Quantum.Diagnostics;\n",
"\n",
@ -162,7 +162,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_Oracle_OddNumberOfOnes_Test\n",
"%kata T14_Oracle_OddNumberOfOnes\n",
"\n",
"operation Oracle_OddNumberOfOnes (x : Qubit[], y : Qubit) : Unit {\n",
" // ...\n",
@ -190,7 +190,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T15_Oracle_ProductFunction_Test\n",
"%kata T15_Oracle_ProductFunction\n",
"\n",
"open Microsoft.Quantum.Diagnostics;\n",
"\n",
@ -230,7 +230,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T16_Oracle_ProductWithNegationFunction_Test\n",
"%kata T16_Oracle_ProductWithNegationFunction\n",
"\n",
"open Microsoft.Quantum.Diagnostics;\n",
"\n",
@ -270,7 +270,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T17_Oracle_HammingWithPrefix_Test\n",
"%kata T17_Oracle_HammingWithPrefix\n",
"\n",
"open Microsoft.Quantum.Diagnostics;\n",
"\n",
@ -310,7 +310,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T18_Oracle_MajorityFunction_Test\n",
"%kata T18_Oracle_MajorityFunction\n",
"\n",
"open Microsoft.Quantum.Diagnostics;\n",
"\n",
@ -360,7 +360,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_DJ_StatePrep_Test\n",
"%kata T21_DJ_StatePrep\n",
"\n",
"operation DJ_StatePrep (query : Qubit[], answer : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -387,7 +387,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_DJ_Algorithm_Test\n",
"%kata T22_DJ_Algorithm\n",
"\n",
"operation DJ_Algorithm (N : Int, oracle : ((Qubit[], Qubit) => Unit)) : Bool {\n",
" // Create a boolean variable for storing the return value.\n",
@ -499,7 +499,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T31_BV_Algorithm_Test\n",
"%kata T31_BV_Algorithm\n",
"\n",
"operation BV_Algorithm (N : Int, oracle : ((Qubit[], Qubit) => Unit)) : Int[] {\n",
" // The algorithm is very similar to Deutsch-Jozsa algorithm; try to implement it without hints.\n",
@ -594,7 +594,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T41_Noname_Algorithm_Test\n",
"%kata T41_Noname_Algorithm\n",
"\n",
"operation Noname_Algorithm (N : Int, oracle : ((Qubit[], Qubit) => Unit)) : Int[] {\n",
" // The algorithm is very similar to Bernstein-Vazirani algorithm; try to implement it without hints.\n",

Просмотреть файл

@ -28,7 +28,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
operation Oracle_Zero_Reference (x : Qubit[], y : Qubit) : Unit is Adj {
// Since f(x) = 0 for all values of x, |y ⊕ f(x)⟩ = |y⟩.
// This means that the operation doesn't need to do any transformation to the inputs.
// Build the project and run the tests to see that T01_Oracle_Zero_Test test passes.
// Build the project and run the tests to see that T01_Oracle_Zero test passes.
}

Просмотреть файл

@ -45,7 +45,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
operation Oracle_Zero (x : Qubit[], y : Qubit) : Unit {
// Since f(x) = 0 for all values of x, |y ⊕ f(x)⟩ = |y⟩.
// This means that the operation doesn't need to do any transformation to the inputs.
// Build the project and run the tests to see that T01_Oracle_Zero_Test test passes.
// Build the project and run the tests to see that T01_Oracle_Zero test passes.
}
@ -211,7 +211,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
// Task 2.3. Testing Deutsch-Jozsa algorithm
// Goal: use your implementation of Deutsch-Jozsa algorithm from task 3.1 to test
// each of the oracles you've implemented in part I for being constant or balanced.
operation DJ_Test () : Unit {
operation DJ () : Unit {
// Hint: use Oracle_ProductFunction to implement the scalar product function oracle passed to DJ_Algorithm.
// Since Oracle_ProductFunction takes three arguments (Qubit[], Qubit and Int[]),
// and the operation passed to DJ_Algorithm must take two arguments (Qubit[] and Qubit),
@ -223,7 +223,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
// Hint: use AllEqualityFactI function to assert that the return value of DJ_Algorithm operation
// matches the expected value (i.e. the bit vector passed to Oracle_ProductFunction).
// DJ_Test appears in the list of unit tests for the solution; run it to verify your code.
// DJ appears in the list of unit tests for the solution; run it to verify your code.
// ...
}
@ -264,13 +264,13 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
// what bit vector the scalar product function oracle from task 1.5 was using.
// As a reminder, this oracle creates an operation f(x) = Σᵢ 𝑟ᵢ 𝑥ᵢ modulo 2 for a given bit vector r,
// and Bernstein-Vazirani algorithm recovers that bit vector given the operation.
operation BV_Test () : Unit {
operation BV () : Unit {
// Hint: you will need to use partial application to test oracles such as Oracle_Kth_Qubit and Oracle_ProductFunction;
// see task 2.3 for a description of how to do that.
// Hint: use the Fact function to assert that the return value of DJ_Algorithm operation matches the expected value
// BV_Test appears in the list of unit tests for the solution; run it to verify your code.
// BV appears in the list of unit tests for the solution; run it to verify your code.
// ...
}

Просмотреть файл

@ -44,21 +44,21 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T11_Oracle_Zero_Test () : Unit {
operation T11_Oracle_Zero () : Unit {
AssertTwoOraclesAreEqual(1 .. 10, Oracle_Zero, Oracle_Zero_Reference);
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T12_Oracle_One_Test () : Unit {
operation T12_Oracle_One () : Unit {
AssertTwoOraclesAreEqual(1 .. 10, Oracle_One, Oracle_One_Reference);
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T13_Oracle_Kth_Qubit_Test () : Unit {
operation T13_Oracle_Kth_Qubit () : Unit {
let maxQ = 6;
// loop over index of the qubit to be used
@ -71,7 +71,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T14_Oracle_OddNumberOfOnes_Test () : Unit {
operation T14_Oracle_OddNumberOfOnes () : Unit {
// cross-test: for 1 qubit it's the same as Kth_Qubit for k = 0
AssertTwoOraclesAreEqual(1 .. 1, Oracle_OddNumberOfOnes, Oracle_Kth_Qubit_Reference(_, _, 0));
@ -88,7 +88,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
}
@Test("QuantumSimulator")
operation T15_Oracle_ProductFunction_Test () : Unit {
operation T15_Oracle_ProductFunction () : Unit {
// cross-tests
// the mask for all 1's corresponds to Oracle_OddNumberOfOnes
mutable r = ConstantArray(10, 1);
@ -121,7 +121,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
}
@Test("QuantumSimulator")
operation T16_Oracle_ProductWithNegationFunction_Test () : Unit {
operation T16_Oracle_ProductWithNegationFunction () : Unit {
// cross-tests
// the mask for all 1's corresponds to Oracle_OddNumberOfOnes
mutable r = ConstantArray(10, 1);
@ -142,7 +142,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
}
@Test("QuantumSimulator")
operation T17_Oracle_HammingWithPrefix_Test () : Unit {
operation T17_Oracle_HammingWithPrefix () : Unit {
mutable prefix = [1];
AssertTwoOraclesAreEqual(1 .. 10, Oracle_HammingWithPrefix(_, _, prefix), Oracle_HammingWithPrefix_Reference(_, _, prefix));
@ -154,14 +154,14 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
}
@Test("QuantumSimulator")
operation T18_Oracle_MajorityFunction_Test () : Unit {
operation T18_Oracle_MajorityFunction () : Unit {
AssertTwoOraclesAreEqual(3 .. 3, Oracle_MajorityFunction, Oracle_MajorityFunction_Reference);
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T21_DJ_StatePrep_Test () : Unit {
operation T21_DJ_StatePrep () : Unit {
for (N in 1 .. 10) {
@ -202,7 +202,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T22_DJ_Algorithm_Test () : Unit {
operation T22_DJ_Algorithm () : Unit {
ResetOracleCallsCount();
@ -260,7 +260,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T31_BV_Algorithm_Test () : Unit {
operation T31_BV_Algorithm () : Unit {
ResetOracleCallsCount();
// test BV the way we suggest the learner to test it:
@ -278,7 +278,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
// ------------------------------------------------------
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T41_Noname_Algorithm_Test () : Unit {
operation T41_Noname_Algorithm () : Unit {
ResetOracleCallsCount();

Просмотреть файл

@ -44,7 +44,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T101_DistinguishIfromX_Test \n",
"%kata T101_DistinguishIfromX \n",
"\n",
"operation DistinguishIfromX (unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n",
" // ...\n",
@ -81,7 +81,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T102_DistinguishIfromZ_Test \n",
"%kata T102_DistinguishIfromZ \n",
"\n",
"operation DistinguishIfromZ (unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n",
" // ...\n",
@ -118,7 +118,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T103_DistinguishZfromS_Test \n",
"%kata T103_DistinguishZfromS \n",
"\n",
"operation DistinguishZfromS (unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n",
" // ...\n",
@ -157,7 +157,7 @@
},
"outputs": [],
"source": [
"%kata T104_DistinguishHfromX_Test \n",
"%kata T104_DistinguishHfromX \n",
"\n",
"operation DistinguishHfromX (unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n",
" // ...\n",
@ -194,7 +194,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T105_DistinguishZfromMinusZ_Test \n",
"%kata T105_DistinguishZfromMinusZ \n",
"\n",
"operation DistinguishZfromMinusZ (unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n",
" // ...\n",
@ -233,7 +233,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T106_DistinguishRzFromR1_Test \n",
"%kata T106_DistinguishRzFromR1 \n",
"\n",
"operation DistinguishRzFromR1 (unitary : ((Double, Qubit) => Unit is Adj+Ctl)) : Int {\n",
" // ...\n",
@ -270,7 +270,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T107_DistinguishYfromXZ_Test \n",
"%kata T107_DistinguishYfromXZ \n",
"\n",
"operation DistinguishYfromXZ (unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n",
" // ...\n",
@ -310,7 +310,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T108_DistinguishYfromXZWithPhases_Test \n",
"%kata T108_DistinguishYfromXZWithPhases \n",
"\n",
"operation DistinguishYfromXZWithPhases (unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n",
" // ...\n",
@ -353,7 +353,7 @@
},
"outputs": [],
"source": [
"%kata T109_DistinguishRzFromRy_Test \n",
"%kata T109_DistinguishRzFromRy \n",
"\n",
"operation DistinguishRzFromRy (theta : Double, unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n",
" // ...\n",
@ -396,7 +396,7 @@
},
"outputs": [],
"source": [
"%kata T110_DistinguishRzFromR1WithAngle_Test \n",
"%kata T110_DistinguishRzFromR1WithAngle \n",
"\n",
"operation DistinguishRzFromR1WithAngle (theta : Double, unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n",
" // ...\n",
@ -431,7 +431,7 @@
},
"outputs": [],
"source": [
"%kata T111_DistinguishPaulis_Test \n",
"%kata T111_DistinguishPaulis \n",
"\n",
"operation DistinguishPaulis (unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n",
" // ...\n",
@ -476,7 +476,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T201_DistinguishIXfromCNOT_Test\n",
"%kata T201_DistinguishIXfromCNOT\n",
"\n",
"operation DistinguishIXfromCNOT (unitary : (Qubit[] => Unit is Adj+Ctl)) : Int {\n",
" // ...\n",
@ -516,7 +516,7 @@
},
"outputs": [],
"source": [
"%kata T202_CNOTDirection_Test\n",
"%kata T202_CNOTDirection\n",
"\n",
"operation CNOTDirection (unitary : (Qubit[] => Unit is Adj+Ctl)) : Int {\n",
" // ...\n",
@ -556,7 +556,7 @@
},
"outputs": [],
"source": [
"%kata T203_DistinguishCNOTfromSWAP_Test\n",
"%kata T203_DistinguishCNOTfromSWAP\n",
"\n",
"operation DistinguishCNOTfromSWAP (unitary : (Qubit[] => Unit is Adj+Ctl)) : Int {\n",
" // ...\n",
@ -601,7 +601,7 @@
},
"outputs": [],
"source": [
"%kata T204_DistinguishTwoQubitUnitaries_Test\n",
"%kata T204_DistinguishTwoQubitUnitaries\n",
"\n",
"operation DistinguishTwoQubitUnitaries (unitary : (Qubit[] => Unit is Adj+Ctl)) : Int {\n",
" // ...\n",

Просмотреть файл

@ -93,28 +93,28 @@ namespace Quantum.Kata.DistinguishUnitaries {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T101_DistinguishIfromX_Test () : Unit {
operation T101_DistinguishIfromX () : Unit {
DistinguishUnitaries_Framework(Mapped(SingleQubitGateAsUnitary<Qubit>, [I, X]), DistinguishIfromX, 1);
}
// ------------------------------------------------------
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T102_DistinguishIfromZ_Test () : Unit {
operation T102_DistinguishIfromZ () : Unit {
DistinguishUnitaries_Framework(Mapped(SingleQubitGateAsUnitary<Qubit>, [I, Z]), DistinguishIfromZ, 1);
}
// ------------------------------------------------------
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T103_DistinguishZfromS_Test () : Unit {
operation T103_DistinguishZfromS () : Unit {
DistinguishUnitaries_Framework(Mapped(SingleQubitGateAsUnitary<Qubit>, [Z, S]), DistinguishZfromS, 2);
}
// ------------------------------------------------------
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T104_DistinguishHfromX_Test () : Unit {
operation T104_DistinguishHfromX () : Unit {
DistinguishUnitaries_Framework(Mapped(SingleQubitGateAsUnitary<Qubit>, [H, X]), DistinguishHfromX, 2);
}
@ -127,35 +127,35 @@ namespace Quantum.Kata.DistinguishUnitaries {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T105_DistinguishZfromMinusZ_Test () : Unit {
operation T105_DistinguishZfromMinusZ () : Unit {
DistinguishUnitaries_Framework(Mapped(SingleQubitGateAsUnitary<Qubit>, [Z, BoundCA([Z, MinusOne])]), DistinguishZfromMinusZ, 1);
}
// ------------------------------------------------------
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T106_DistinguishRzFromR1_Test () : Unit {
operation T106_DistinguishRzFromR1 () : Unit {
DistinguishUnitaries_Framework(Mapped(SingleQubitGateAsUnitary<(Double, Qubit)>, [Rz, R1]), DistinguishRzFromR1, 1);
}
// ------------------------------------------------------
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T107_DistinguishYfromXZ_Test () : Unit {
operation T107_DistinguishYfromXZ () : Unit {
DistinguishUnitaries_Framework(Mapped(SingleQubitGateAsUnitary<Qubit>, [Y, BoundCA([Z, X])]), DistinguishYfromXZ, 2);
}
// ------------------------------------------------------
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T108_DistinguishYfromXZWithPhases_Test () : Unit {
operation T108_DistinguishYfromXZWithPhases () : Unit {
DistinguishUnitaries_Framework(Mapped(SingleQubitGateAsUnitary<Qubit>, [Y, BoundCA([Z, X, MinusOne]), BoundCA([Y, MinusOne]), BoundCA([Z, X])]), DistinguishYfromXZWithPhases, 3);
}
// ------------------------------------------------------
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T109_DistinguishRzFromRy_Test () : Unit {
operation T109_DistinguishRzFromRy () : Unit {
for (theta in [0.04, 0.1, 0.25, 0.31, 0.5, 0.87, 1.05, 1.41, 1.66, 1.75, 2.0, 2.16, 2.22, 2.51, 2.93, 3.0, 3.1]) {
DistinguishUnitaries_Framework(Mapped(SingleQubitGateAsUnitary<Qubit>, [Rz(theta, _), Ry(theta, _)]), DistinguishRzFromRy(theta, _), -1);
}
@ -164,7 +164,7 @@ namespace Quantum.Kata.DistinguishUnitaries {
// ------------------------------------------------------
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T110_DistinguishRzFromR1WithAngle_Test () : Unit {
operation T110_DistinguishRzFromR1WithAngle () : Unit {
for (theta in [0.04, 0.1, 0.25, 0.31, 0.5, 0.87, 1.05, 1.41, 1.66, 1.75, 2.0, 2.16, 2.22, 2.51, 2.93, 3.0, 3.1]) {
DistinguishUnitaries_Framework(Mapped(SingleQubitGateAsUnitary<Qubit>, [Rz(theta, _), R1(theta, _)]), DistinguishRzFromR1WithAngle(theta, _), -1);
}
@ -173,7 +173,7 @@ namespace Quantum.Kata.DistinguishUnitaries {
// ------------------------------------------------------
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T111_DistinguishPaulis_Test () : Unit {
operation T111_DistinguishPaulis () : Unit {
DistinguishUnitaries_Framework(Mapped(SingleQubitGateAsUnitary<Qubit>, [I, X, Y, Z]), DistinguishPaulis, 1);
}
@ -193,7 +193,7 @@ namespace Quantum.Kata.DistinguishUnitaries {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T201_DistinguishIXfromCNOT_Test () : Unit {
operation T201_DistinguishIXfromCNOT () : Unit {
DistinguishUnitaries_Framework([IXWrapper, CNOTWrapper], DistinguishIXfromCNOT, 1);
}
@ -204,7 +204,7 @@ namespace Quantum.Kata.DistinguishUnitaries {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T202_CNOTDirection_Test () : Unit {
operation T202_CNOTDirection () : Unit {
DistinguishUnitaries_Framework([CNOTWrapper, ReverseCNOTWrapper], CNOTDirection, 1);
}
@ -215,7 +215,7 @@ namespace Quantum.Kata.DistinguishUnitaries {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T203_DistinguishCNOTfromSWAP_Test () : Unit {
operation T203_DistinguishCNOTfromSWAP () : Unit {
DistinguishUnitaries_Framework([CNOTWrapper, SWAPWrapper], DistinguishCNOTfromSWAP, 1);
}
@ -225,7 +225,7 @@ namespace Quantum.Kata.DistinguishUnitaries {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T204_DistinguishTwoQubitUnitaries_Test () : Unit {
operation T204_DistinguishTwoQubitUnitaries () : Unit {
DistinguishUnitaries_Framework([IdentityWrapper, CNOTWrapper, ReverseCNOTWrapper, SWAPWrapper], DistinguishTwoQubitUnitaries, 2);
}
}

Просмотреть файл

@ -83,7 +83,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T101_DistinguishIfromX_Test \n",
"%kata T101_DistinguishIfromX \n",
"\n",
"operation DistinguishIfromX (unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n",
" using (q = Qubit()) {\n",
@ -145,7 +145,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T102_DistinguishIfromZ_Test \n",
"%kata T102_DistinguishIfromZ \n",
"\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
@ -204,7 +204,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T103_DistinguishZfromS_Test \n",
"%kata T103_DistinguishZfromS \n",
"\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
@ -258,7 +258,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T104_DistinguishHfromX_Test \n",
"%kata T104_DistinguishHfromX \n",
"\n",
"operation DistinguishHfromX (unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n",
" using (q = Qubit()) {\n",
@ -330,7 +330,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T105_DistinguishZfromMinusZ_Test \n",
"%kata T105_DistinguishZfromMinusZ \n",
"\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
@ -394,7 +394,7 @@
},
"outputs": [],
"source": [
"%kata T106_DistinguishRzFromR1_Test \n",
"%kata T106_DistinguishRzFromR1 \n",
"\n",
"open Microsoft.Quantum.Math;\n",
"\n",
@ -454,7 +454,7 @@
},
"outputs": [],
"source": [
"%kata T107_DistinguishYfromXZ_Test \n",
"%kata T107_DistinguishYfromXZ \n",
"\n",
"operation DistinguishYfromXZ (unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n",
" using (qs = Qubit[2]) {\n",
@ -516,7 +516,7 @@
},
"outputs": [],
"source": [
"%kata T108_DistinguishYfromXZWithPhases_Test \n",
"%kata T108_DistinguishYfromXZWithPhases \n",
"\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
@ -586,7 +586,7 @@
},
"outputs": [],
"source": [
"%kata T108_DistinguishYfromXZWithPhases_Test \n",
"%kata T108_DistinguishYfromXZWithPhases \n",
"\n",
"open Microsoft.Quantum.Arithmetic;\n",
"open Microsoft.Quantum.Characterization;\n",
@ -695,7 +695,7 @@
},
"outputs": [],
"source": [
"%kata T109_DistinguishRzFromRy_Test \n",
"%kata T109_DistinguishRzFromRy \n",
"\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
@ -771,7 +771,7 @@
},
"outputs": [],
"source": [
"%kata T111_DistinguishPaulis_Test \n",
"%kata T111_DistinguishPaulis \n",
"\n",
"operation DistinguishPaulis (unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n",
" // apply operation to the 1st qubit of a Bell state and measure in Bell basis\n",
@ -849,7 +849,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T201_DistinguishIXfromCNOT_Test\n",
"%kata T201_DistinguishIXfromCNOT\n",
"\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
@ -911,7 +911,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T202_CNOTDirection_Test\n",
"%kata T202_CNOTDirection\n",
"\n",
"operation CNOTDirection (unitary : (Qubit[] => Unit is Adj+Ctl)) : Int {\n",
" using (qs = Qubit[2]) {\n",
@ -972,7 +972,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T203_DistinguishCNOTfromSWAP_Test\n",
"%kata T203_DistinguishCNOTfromSWAP\n",
"\n",
"operation DistinguishCNOTfromSWAP (unitary : (Qubit[] => Unit is Adj+Ctl)) : Int {\n",
" using (qs = Qubit[2]) {\n",
@ -1031,7 +1031,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T204_DistinguishTwoQubitUnitaries_Test\n",
"%kata T204_DistinguishTwoQubitUnitaries\n",
"\n",
"open Microsoft.Quantum.Arithmetic;\n",
"\n",

Просмотреть файл

@ -59,7 +59,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_WinCondition_Test \n",
"%kata T11_WinCondition \n",
"\n",
"function WinCondition (rst : Bool[], abc : Bool[]) : Bool {\n",
" // ...\n",
@ -93,7 +93,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_RandomClassical_Test \n",
"%kata T12_RandomClassical \n",
"\n",
"operation RandomClassicalStrategy (input : Bool) : Bool {\n",
" // ...\n",
@ -128,7 +128,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T13_BestClassical_Test \n",
"%kata T13_BestClassical \n",
"\n",
"operation BestClassicalStrategy (input : Bool) : Bool {\n",
" // ...\n",
@ -165,7 +165,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_PlayClassicalGHZ_Test \n",
"%kata T14_PlayClassicalGHZ \n",
"\n",
"operation PlayClassicalGHZ (strategy : (Bool => Bool), inputs : Bool[]) : Bool[] {\n",
" // ...\n",
@ -208,7 +208,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_CreateEntangledTriple_Test \n",
"%kata T21_CreateEntangledTriple \n",
"\n",
"operation CreateEntangledTriple (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -246,7 +246,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_QuantumStrategy_Test \n",
"%kata T22_QuantumStrategy \n",
"\n",
"operation QuantumStrategy (input : Bool, qubit : Qubit) : Bool {\n",
" // ...\n",
@ -280,7 +280,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T23_PlayQuantumGHZ_Test \n",
"%kata T23_PlayQuantumGHZ \n",
"\n",
"operation PlayQuantumGHZ (strategies : (Qubit => Bool)[]) : Bool[] {\n",
" // ...\n",

Просмотреть файл

@ -25,7 +25,7 @@ namespace Quantum.Kata.GHZGame {
}
@Test("QuantumSimulator")
operation T11_WinCondition_Test () : Unit {
operation T11_WinCondition () : Unit {
for (rst in RefereeBits()) {
for (i in 0 .. 1 <<< 3 - 1) {
let abc = IntAsBoolArray(i, 3);
@ -53,14 +53,14 @@ namespace Quantum.Kata.GHZGame {
}
@Test("QuantumSimulator")
operation T12_RandomClassical_Test () : Unit {
operation T12_RandomClassical () : Unit {
EqualityWithinToleranceFact(GetClassicalStrategySuccessRate(10000, RandomClassicalStrategy), 0.5, 0.02);
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T13_BestClassical_Test () : Unit {
operation T13_BestClassical () : Unit {
EqualityWithinToleranceFact(GetClassicalStrategySuccessRate(10000, BestClassicalStrategy), 0.75, 0.02);
}
@ -71,7 +71,7 @@ namespace Quantum.Kata.GHZGame {
}
@Test("QuantumSimulator")
operation T14_PlayClassicalGHZ_Test () : Unit {
operation T14_PlayClassicalGHZ () : Unit {
// To test the interaction, run it on several deterministic strategies (not necessarily good ones)
let inputs = RefereeBits();
for (rst in inputs) {
@ -101,14 +101,14 @@ namespace Quantum.Kata.GHZGame {
}
@Test("QuantumSimulator")
operation T21_CreateEntangledTriple_Test () : Unit {
operation T21_CreateEntangledTriple () : Unit {
AssertEqualOnZeroState(3, CreateEntangledTriple, CreateEntangledTriple_Reference);
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T22_QuantumStrategy_Test () : Unit {
operation T22_QuantumStrategy () : Unit {
for (_ in 1 .. 4) {
// repeat 4 times since we are testing a measurement, it's possible to get
// correct answer with wrong basis, reduces probability of false positives
@ -135,7 +135,7 @@ namespace Quantum.Kata.GHZGame {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T23_PlayQuantumGHZ_Test () : Unit {
operation T23_PlayQuantumGHZ () : Unit {
for (_ in 0 .. 1000) {
let rst = (RefereeBits())[DrawRandomInt(0, Length(RefereeBits()) - 1)];
let strategies = [QuantumStrategy_Reference(rst[0], _),

Просмотреть файл

@ -58,7 +58,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_WinCondition_Test \n",
"%kata T11_WinCondition \n",
"\n",
"open Microsoft.Quantum.Logical;\n",
"\n",
@ -104,7 +104,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_RandomClassical_Test \n",
"%kata T12_RandomClassical \n",
"\n",
"open Microsoft.Quantum.Random;\n",
"\n",
@ -152,7 +152,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T13_BestClassical_Test \n",
"%kata T13_BestClassical \n",
"\n",
"operation BestClassicalStrategy (input : Bool) : Bool {\n",
" return true;\n",
@ -197,7 +197,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_PlayClassicalGHZ_Test \n",
"%kata T14_PlayClassicalGHZ \n",
"\n",
"operation PlayClassicalGHZ (strategy : (Bool => Bool), inputs : Bool[]) : Bool[] {\n",
" let r = inputs[0];\n",
@ -223,7 +223,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_PlayClassicalGHZ_Test \n",
"%kata T14_PlayClassicalGHZ \n",
"\n",
"open Microsoft.Quantum.Arrays;\n",
"\n",
@ -283,7 +283,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_CreateEntangledTriple_Test \n",
"%kata T21_CreateEntangledTriple \n",
"\n",
"operation CreateEntangledTriple (qs : Qubit[]) : Unit {\n",
" X(qs[0]);\n",
@ -342,7 +342,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_QuantumStrategy_Test \n",
"%kata T22_QuantumStrategy \n",
"\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
@ -371,7 +371,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_QuantumStrategy_Test \n",
"%kata T22_QuantumStrategy \n",
"\n",
"operation QuantumStrategy (input : Bool, qubit : Qubit) : Bool {\n",
" if (input) {\n",
@ -545,7 +545,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T23_PlayQuantumGHZ_Test \n",
"%kata T23_PlayQuantumGHZ \n",
"\n",
"operation PlayQuantumGHZ (strategies : (Qubit => Bool)[]) : Bool[] {\n",
" using (ghz = Qubit[3]) {\n",

Просмотреть файл

@ -56,7 +56,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_InitializeColor_Test \n",
"%kata T11_InitializeColor \n",
"\n",
"operation InitializeColor (C : Int, register : Qubit[]) : Unit is Adj {\n",
" // ...\n",
@ -92,7 +92,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_MeasureColor_Test \n",
"%kata T12_MeasureColor \n",
"\n",
"operation MeasureColor (register : Qubit[]) : Int {\n",
" // ...\n",
@ -135,7 +135,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T13_MeasureColoring_Test \n",
"%kata T13_MeasureColoring \n",
"\n",
"operation MeasureColoring (K : Int, register : Qubit[]) : Int[] {\n",
" // ...\n",
@ -179,7 +179,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_ColorEqualityOracle_2bit_Test \n",
"%kata T14_ColorEqualityOracle_2bit \n",
"\n",
"operation ColorEqualityOracle_2bit (c0 : Qubit[], c1 : Qubit[], target : Qubit) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -208,7 +208,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T15_ColorEqualityOracle_Nbit_Test \n",
"%kata T15_ColorEqualityOracle_Nbit \n",
"\n",
"operation ColorEqualityOracle_Nbit (c0 : Qubit[], c1 : Qubit[], target : Qubit) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -262,7 +262,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_IsVertexColoringValid_Test \n",
"%kata T21_IsVertexColoringValid \n",
"\n",
"function IsVertexColoringValid (V : Int, edges: (Int, Int)[], colors: Int[]) : Bool {\n",
" // ...\n",
@ -311,7 +311,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_VertexColoringOracle_Test \n",
"%kata T22_VertexColoringOracle \n",
"\n",
"operation VertexColoringOracle (V : Int, \n",
" edges : (Int, Int)[], \n",
@ -351,7 +351,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T23_GroversAlgorithm_Test \n",
"%kata T23_GroversAlgorithm \n",
"\n",
"operation GroversAlgorithm (V : Int, oracle : ((Qubit[], Qubit) => Unit is Adj)) : Int[] {\n",
" // ...\n",

Просмотреть файл

@ -24,7 +24,7 @@ namespace Quantum.Kata.GraphColoring {
//////////////////////////////////////////////////////////////////
@Test("QuantumSimulator")
operation T11_InitializeColor_Test () : Unit {
operation T11_InitializeColor () : Unit {
for (N in 1 .. 4) {
using (register = Qubit[N]) {
for (C in 0 .. (1 <<< N) - 1) {
@ -41,7 +41,7 @@ namespace Quantum.Kata.GraphColoring {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T12_MeasureColor_Test () : Unit {
operation T12_MeasureColor () : Unit {
for (N in 1 .. 4) {
using (register = Qubit[N]) {
for (C in 0 .. (1 <<< N) - 1) {
@ -63,7 +63,7 @@ namespace Quantum.Kata.GraphColoring {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T13_MeasureColoring_Test () : Unit {
operation T13_MeasureColoring () : Unit {
for (K in 1 .. 3) {
for (N in 1 .. 3) {
using (register = Qubit[N * K]) {
@ -127,7 +127,7 @@ namespace Quantum.Kata.GraphColoring {
}
@Test("QuantumSimulator")
operation T14_ColorEqualityOracle_2bit_Test () : Unit {
operation T14_ColorEqualityOracle_2bit () : Unit {
CheckColorEqualityOracle(2, ColorEqualityOracle_2bit);
AssertOperationsEqualReferenced(5, WrapperOperation(ColorEqualityOracle_2bit, _),
WrapperOperation(ColorEqualityOracle_2bit_Reference, _));
@ -136,7 +136,7 @@ namespace Quantum.Kata.GraphColoring {
// ------------------------------------------------------
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T15_ColorEqualityOracle_Nbit_Test () : Unit {
operation T15_ColorEqualityOracle_Nbit () : Unit {
for (N in 1..4) {
ResetQubitCount();
@ -175,7 +175,7 @@ namespace Quantum.Kata.GraphColoring {
}
@Test("QuantumSimulator")
operation T21_IsVertexColoringValid_Test () : Unit {
operation T21_IsVertexColoringValid () : Unit {
let testCases = ExampleGraphs();
let (V0, edges0) = testCases[0];
@ -256,7 +256,7 @@ namespace Quantum.Kata.GraphColoring {
}
@Test("QuantumSimulator")
operation T22_VertexColoringOracle_Test () : Unit {
operation T22_VertexColoringOracle () : Unit {
// Run test on all test cases except the last one
for ((V, edges) in Most(ExampleGraphs())) {
AssertOracleRecognizesColoring(V, edges, VertexColoringOracle);
@ -264,7 +264,7 @@ namespace Quantum.Kata.GraphColoring {
}
@Test("QuantumSimulator")
operation T23_GroversAlgorithm_Test () : Unit {
operation T23_GroversAlgorithm () : Unit {
for ((V, edges) in ExampleGraphs()) {
Message($"Running on graph V = {V}, edges = {edges}");
let coloring = GroversAlgorithm(V, VertexColoringOracle_Reference(V, edges, _, _));

Просмотреть файл

@ -60,7 +60,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_InitializeColor_Test \n",
"%kata T11_InitializeColor \n",
"\n",
"open Microsoft.Quantum.Convert;\n",
"\n",
@ -107,7 +107,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_InitializeColor_Test \n",
"%kata T11_InitializeColor \n",
"\n",
"open Microsoft.Quantum.Convert;\n",
"\n",
@ -163,7 +163,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_MeasureColor_Test \n",
"%kata T12_MeasureColor \n",
"\n",
"open Microsoft.Quantum.Convert;\n",
"open Microsoft.Quantum.Measurement;\n",
@ -228,7 +228,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T13_MeasureColoring_Test \n",
"%kata T13_MeasureColoring \n",
"\n",
"open Microsoft.Quantum.Arrays;\n",
"\n",
@ -298,7 +298,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_ColorEqualityOracle_2bit_Test \n",
"%kata T14_ColorEqualityOracle_2bit \n",
"\n",
"operation ColorEqualityOracle_2bit (c0 : Qubit[], c1 : Qubit[], target : Qubit) : Unit is Adj+Ctl {\n",
" using (a = Qubit[2]) {\n",
@ -352,7 +352,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T15_ColorEqualityOracle_Nbit_Test \n",
"%kata T15_ColorEqualityOracle_Nbit \n",
"\n",
"operation ColorEqualityOracle_Nbit (c0 : Qubit[], c1 : Qubit[], target : Qubit) : Unit is Adj+Ctl {\n",
" within {\n",
@ -423,7 +423,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_IsVertexColoringValid_Test \n",
"%kata T21_IsVertexColoringValid \n",
"\n",
"function IsVertexColoringValid (V : Int, edges: (Int, Int)[], colors: Int[]) : Bool {\n",
" // ...\n",
@ -481,7 +481,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_VertexColoringOracle_Test \n",
"%kata T22_VertexColoringOracle \n",
"\n",
"operation VertexColoringOracle (V : Int, \n",
" edges : (Int, Int)[], \n",
@ -530,7 +530,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T23_GroversAlgorithm_Test \n",
"%kata T23_GroversAlgorithm \n",
"\n",
"operation GroversAlgorithm (V : Int, oracle : ((Qubit[], Qubit) => Unit is Adj)) : Int[] {\n",
" // ...\n",

Просмотреть файл

@ -77,7 +77,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_Oracle_AllOnes_Test \n",
"%kata T11_Oracle_AllOnes \n",
"\n",
"operation Oracle_AllOnes (queryRegister : Qubit[], target : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -115,7 +115,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_Oracle_AlternatingBits_Test \n",
"%kata T12_Oracle_AlternatingBits \n",
"\n",
"operation Oracle_AlternatingBits (queryRegister : Qubit[], target : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -154,7 +154,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T13_Oracle_ArbitraryPattern_Test \n",
"%kata T13_Oracle_ArbitraryPattern \n",
"\n",
"operation Oracle_ArbitraryPattern (queryRegister : Qubit[], target : Qubit, pattern : Bool[]) : Unit is Adj {\n",
" // ...\n",
@ -195,7 +195,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_OracleConverter_Test \n",
"%kata T14_OracleConverter \n",
"\n",
"function OracleConverter (markingOracle : ((Qubit[], Qubit) => Unit is Adj)) : (Qubit[] => Unit is Adj) {\n",
" // ...\n",
@ -229,7 +229,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_HadamardTransform_Test \n",
"%kata T21_HadamardTransform \n",
"\n",
"operation HadamardTransform (register : Qubit[]) : Unit is Adj {\n",
" // ...\n",
@ -279,7 +279,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_ConditionalPhaseFlip_Test \n",
"%kata T22_ConditionalPhaseFlip \n",
"\n",
"operation ConditionalPhaseFlip (register : Qubit[]) : Unit is Adj {\n",
" // ...\n",
@ -320,7 +320,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T23_GroverIteration_Test \n",
"%kata T23_GroverIteration \n",
"\n",
"operation GroverIteration (register : Qubit[], oracle : (Qubit[] => Unit is Adj)) : Unit is Adj {\n",
" // ...\n",
@ -360,7 +360,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T31_GroversSearch_Test \n",
"%kata T31_GroversSearch \n",
"\n",
"operation GroversSearch (register : Qubit[], oracle : ((Qubit[], Qubit) => Unit is Adj), iterations : Int) : Unit {\n",
" // ...\n",

Просмотреть файл

@ -186,7 +186,7 @@ namespace Quantum.Kata.GroversAlgorithm {
// Goal: Use your implementation of Grover's algorithm from task 3.1 and the oracles from part 1
// to find the marked elements of the search space.
// This task is not covered by a test and allows you to experiment with running the algorithm.
operation E2E_GroversSearch_Test () : Unit {
operation E2E_GroversSearch () : Unit {
// Hint 1: To check whether the algorithm found the correct answer (i.e., an answer marked as 1 by the oracle),
// you can apply the oracle once more to the register after you've measured it and an ancilla qubit,

Просмотреть файл

@ -35,7 +35,7 @@ namespace Quantum.Kata.GroversAlgorithm {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T11_Oracle_AllOnes_Test () : Unit {
operation T11_Oracle_AllOnes () : Unit {
let testOp = QubitArrayWrapperOperation(Oracle_AllOnes, _);
let refOp = QubitArrayWrapperOperation(Oracle_AllOnes_Reference, _);
AssertRegisterOperationsEqual(testOp, refOp);
@ -44,7 +44,7 @@ namespace Quantum.Kata.GroversAlgorithm {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T12_Oracle_AlternatingBits_Test () : Unit {
operation T12_Oracle_AlternatingBits () : Unit {
let testOp = QubitArrayWrapperOperation(Oracle_AlternatingBits, _);
let refOp = QubitArrayWrapperOperation(Oracle_AlternatingBits_Reference, _);
AssertRegisterOperationsEqual(testOp, refOp);
@ -53,7 +53,7 @@ namespace Quantum.Kata.GroversAlgorithm {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T13_Oracle_ArbitraryPattern_Test () : Unit {
operation T13_Oracle_ArbitraryPattern () : Unit {
for (n in 2 .. 10) {
let pattern = IntAsBoolArray(DrawRandomInt(0, 2^n - 1), n);
let testOp = QubitArrayWrapperOperation(Oracle_ArbitraryPattern(_, _, pattern), _);
@ -65,7 +65,7 @@ namespace Quantum.Kata.GroversAlgorithm {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T14_OracleConverter_Test () : Unit {
operation T14_OracleConverter () : Unit {
for (n in 2 .. 10) {
let pattern = IntAsBoolArray(DrawRandomInt(0, 2^n - 1), n);
let markingOracle = Oracle_ArbitraryPattern_Reference(_, _, pattern);
@ -78,21 +78,21 @@ namespace Quantum.Kata.GroversAlgorithm {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T21_HadamardTransform_Test () : Unit {
operation T21_HadamardTransform () : Unit {
AssertRegisterOperationsEqual(HadamardTransform, HadamardTransform_Reference);
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T22_ConditionalPhaseFlip_Test () : Unit {
operation T22_ConditionalPhaseFlip () : Unit {
AssertRegisterOperationsEqual(ConditionalPhaseFlip, ConditionalPhaseFlip_Reference);
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T23_GroverIteration_Test () : Unit {
operation T23_GroverIteration () : Unit {
for (n in 2 .. 10) {
let pattern = IntAsBoolArray(DrawRandomInt(0, 2^n - 1), n);
let markingOracle = Oracle_ArbitraryPattern_Reference(_, _, pattern);
@ -106,7 +106,7 @@ namespace Quantum.Kata.GroversAlgorithm {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T31_GroversSearch_Test () : Unit {
operation T31_GroversSearch () : Unit {
for (n in 2 .. 10) {
let pattern = IntAsBoolArray(DrawRandomInt(0, 2^n - 1), n);
let markingOracle = Oracle_ArbitraryPattern_Reference(_, _, pattern);

Просмотреть файл

@ -41,7 +41,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T01_SingleQubitMeasurement_Test \n",
"%kata T01_SingleQubitMeasurement \n",
"\n",
"operation SingleQubitMeasurement (qs : Qubit[]) : Int {\n",
" // ...\n",
@ -74,7 +74,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T02_ParityMeasurement_Test \n",
"%kata T02_ParityMeasurement \n",
"\n",
"operation ParityMeasurement (qs : Qubit[]) : Int {\n",
" // ...\n",
@ -106,7 +106,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T03_GHZOrGHZWithX_Test \n",
"%kata T03_GHZOrGHZWithX \n",
"\n",
"operation GHZOrGHZWithX (qs : Qubit[]) : Int {\n",
" // ...\n",
@ -139,7 +139,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T04_GHZOrWState_Test\n",
"%kata T04_GHZOrWState\n",
"\n",
"operation GHZOrWState (qs : Qubit[]) : Int {\n",
" // ...\n",
@ -174,7 +174,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T05_DifferentBasis_Test\n",
"%kata T05_DifferentBasis\n",
"\n",
"operation DifferentBasis (qs : Qubit[]) : Int {\n",
" // ...\n",
@ -206,7 +206,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T06_ControlledX_Test\n",
"%kata T06_ControlledX\n",
"\n",
"operation ControlledX (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -244,7 +244,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T07_ControlledX_General_Test\n",
"%kata T07_ControlledX_General\n",
"\n",
"operation ControlledX_General (qs : Qubit[]) : Unit {\n",
" // ...\n",

Просмотреть файл

@ -104,21 +104,21 @@ namespace Quantum.Kata.JointMeasurements {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T01_SingleQubitMeasurement_Test () : Unit {
operation T01_SingleQubitMeasurement () : Unit {
DistinguishStates_MultiQubit(2, 2, StatePrep_ParityMeasurement, SingleQubitMeasurement, false, ["α|00⟩ + β|11⟩", "α|01⟩ + β|10⟩"]);
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T02_ParityMeasurement_Test () : Unit {
operation T02_ParityMeasurement () : Unit {
DistinguishStates_MultiQubit(2, 2, StatePrep_ParityMeasurement, ParityMeasurement, true, ["α|00⟩ + β|11⟩", "α|01⟩ + β|10⟩"]);
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T03_GHZOrGHZWithX_Test () : Unit {
operation T03_GHZOrGHZWithX () : Unit {
DistinguishStates_MultiQubit(4, 2, StatePrep_ParityMeasurement, GHZOrGHZWithX, true, ["α|0000⟩ + β|1111⟩", "α|0011⟩ + β|1100⟩"]);
}
@ -156,7 +156,7 @@ namespace Quantum.Kata.JointMeasurements {
@Test("QuantumSimulator")
operation T04_GHZOrWState_Test () : Unit {
operation T04_GHZOrWState () : Unit {
for (i in 1 .. 5) {
DistinguishStates_MultiQubit(2 * i, 2, StatePrep_GHZOrWState, GHZOrWState, true, ["GHZ State", "W State"]);
}
@ -179,7 +179,7 @@ namespace Quantum.Kata.JointMeasurements {
}
@Test("QuantumSimulator")
operation T05_DifferentBasis_Test () : Unit {
operation T05_DifferentBasis () : Unit {
DistinguishStates_MultiQubit(2, 2, StatePrep_DifferentBasis, DifferentBasis, true,
["α|00⟩ + β|01⟩ + β|10⟩ + α|11⟩", "α|00⟩ - β|01⟩ + β|10⟩ - α|11⟩"]);
}
@ -203,7 +203,7 @@ namespace Quantum.Kata.JointMeasurements {
// ------------------------------------------------------
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T06_ControlledX_Test () : Unit {
operation T06_ControlledX () : Unit {
// Note that the way the problem is formulated, we can't just compare two unitaries,
// we need to create an input state |A⟩ and check that the output state is correct
using (qs = Qubit[2]) {
@ -240,7 +240,7 @@ namespace Quantum.Kata.JointMeasurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T07_ControlledX_General_Test () : Unit {
operation T07_ControlledX_General () : Unit {
// In this task the gate is supposed to work on all inputs, so we can compare the unitary to CNOT.
AssertOperationsEqualReferenced(2, CNOTWrapper, ControlledX_General_Reference);
AssertOperationsEqualReferenced(2, ControlledX_General, ControlledX_General_Reference);

Просмотреть файл

@ -54,7 +54,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T01_SingleQubitMeasurement_Test\n",
"%kata T01_SingleQubitMeasurement\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
"operation SingleQubitMeasurement (qs : Qubit[]) : Int {\n",
@ -145,7 +145,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T02_ParityMeasurement_Test\n",
"%kata T02_ParityMeasurement\n",
"\n",
"operation ParityMeasurement (qs : Qubit[]) : Int {\n",
" return Measure([PauliZ, PauliZ], qs) == Zero ? 0 | 1;\n",
@ -186,7 +186,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T03_GHZOrGHZWithX_Test \n",
"%kata T03_GHZOrGHZWithX \n",
"\n",
"operation GHZOrGHZWithX (qs : Qubit[]) : Int {\n",
" return Measure([PauliZ, PauliZ], qs[1 .. 2]) == Zero ? 0 | 1;\n",
@ -231,7 +231,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T04_GHZOrWState_Test\n",
"%kata T04_GHZOrWState\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
"operation GHZOrWState (qs : Qubit[]) : Int {\n",
@ -317,7 +317,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T05_DifferentBasis_Test\n",
"%kata T05_DifferentBasis\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
"operation DifferentBasis (qs : Qubit[]) : Int {\n",
@ -367,7 +367,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T06_ControlledX_Test\n",
"%kata T06_ControlledX\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
"operation ControlledX (qs : Qubit[]) : Unit {\n",
@ -476,7 +476,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T07_ControlledX_General_Test\n",
"%kata T07_ControlledX_General\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
"operation ControlledX_General (qs : Qubit[]) : Unit {\n",

Просмотреть файл

@ -80,7 +80,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_DiagonalBasis_Test\n",
"%kata T11_DiagonalBasis\n",
"\n",
"operation DiagonalBasis (qs : Qubit[]) : Unit { \n",
" // ...\n",
@ -107,7 +107,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_EqualSuperposition_Test \n",
"%kata T12_EqualSuperposition \n",
"\n",
"operation EqualSuperposition (q : Qubit) : Unit {\n",
" // ...\n",
@ -151,7 +151,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_RandomArray_Test \n",
"%kata T21_RandomArray \n",
"\n",
"operation RandomArray (N : Int) : Bool[] {\n",
" // ...\n",
@ -186,7 +186,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_PrepareAlicesQubits_Test\n",
"%kata T22_PrepareAlicesQubits\n",
"\n",
"operation PrepareAlicesQubits (qs : Qubit[], bases : Bool[], bits : Bool[]) : Unit {\n",
" // ...\n",
@ -220,7 +220,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T23_MeasureBobsQubits_Test\n",
"%kata T23_MeasureBobsQubits\n",
"\n",
"operation MeasureBobsQubits (qs : Qubit[], bases : Bool[]) : Bool[] {\n",
" // ...\n",
@ -253,7 +253,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T24_GenerateSharedKey_Test\n",
"%kata T24_GenerateSharedKey\n",
"\n",
"function GenerateSharedKey (basesAlice : Bool[], basesBob : Bool[], measurementsBob : Bool[]) : Bool[] {\n",
" // ...\n",
@ -284,7 +284,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T25_CheckKeysMatch_Test\n",
"%kata T25_CheckKeysMatch\n",
"\n",
"function CheckKeysMatch (keyAlice : Bool[], keyBob : Bool[], errorRate : Int) : Bool {\n",
" // ...\n",
@ -384,7 +384,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T31_Eavesdrop_Test\n",
"%kata T31_Eavesdrop\n",
"\n",
"operation Eavesdrop (q : Qubit, basis : Bool) : Bool {\n",
" // ...\n",

Просмотреть файл

@ -202,8 +202,8 @@ namespace Quantum.Kata.KeyDistribution {
// and following the comments in the operation template.
//
// This is an open-ended task and is not covered by a test;
// you can run T26_BB84Protocol_Test to run your code.
operation T26_BB84Protocol_Test () : Unit {
// you can run T26_BB84Protocol to run your code.
operation T26_BB84Protocol () : Unit {
// 1. Alice chooses a random set of bits to encode in her qubits
// and a random set of bases to prepare her qubits in.
// ...
@ -267,8 +267,8 @@ namespace Quantum.Kata.KeyDistribution {
// Note that now we should be able to detect Eve and therefore we have to discard some of our key bits!
//
// This is an open-ended task and is not covered by a test;
// you can run T32_BB84ProtocolWithEavesdropper_Test to run your code.
operation T32_BB84ProtocolWithEavesdropper_Test () : Unit {
// you can run T32_BB84ProtocolWithEavesdropper to run your code.
operation T32_BB84ProtocolWithEavesdropper () : Unit {
// ...
}
}

Просмотреть файл

@ -22,14 +22,14 @@ namespace Quantum.Kata.KeyDistribution {
//////////////////////////////////////////////////////////////////
@Test("QuantumSimulator")
operation T11_DiagonalBasis_Test () : Unit {
operation T11_DiagonalBasis () : Unit {
for (i in 1 .. 5) {
AssertOperationsEqualReferenced(i, DiagonalBasis, DiagonalBasis_Reference);
}
}
@Test("QuantumSimulator")
operation T12_EqualSuperposition_Test () : Unit {
operation T12_EqualSuperposition () : Unit {
using (q = Qubit()) {
EqualSuperposition(q);
DumpMachine();
@ -44,7 +44,7 @@ namespace Quantum.Kata.KeyDistribution {
//////////////////////////////////////////////////////////////////
@Test("QuantumSimulator")
operation T21_RandomArray_Test () : Unit {
operation T21_RandomArray () : Unit {
// The test checks that the operation does not return always the same array.
let N = 30;
let randomArrays = ForEach(RandomArray, [N, N, N]);
@ -66,7 +66,7 @@ namespace Quantum.Kata.KeyDistribution {
}
@Test("QuantumSimulator")
operation T22_PrepareAlicesQubits_Test () : Unit {
operation T22_PrepareAlicesQubits () : Unit {
for (N in 2 .. 10) {
let (bases, state) = GenerateRandomState(N);
using (qs = Qubit[N]) {
@ -80,7 +80,7 @@ namespace Quantum.Kata.KeyDistribution {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T23_MeasureBobsQubits_Test () : Unit {
operation T23_MeasureBobsQubits () : Unit {
for (N in 2 .. 10) {
let (bases, state) = GenerateRandomState(N);
using (qs = Qubit[N]) {
@ -97,7 +97,7 @@ namespace Quantum.Kata.KeyDistribution {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T24_GenerateSharedKey_Test () : Unit {
operation T24_GenerateSharedKey () : Unit {
for (N in 10 .. 30) {
let basesAlice = RandomArray_Reference(N);
let (basesBob, bitsBob) = GenerateRandomState(N);
@ -112,7 +112,7 @@ namespace Quantum.Kata.KeyDistribution {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T25_CheckKeysMatch_Test () : Unit {
operation T25_CheckKeysMatch () : Unit {
// Hard-coded test to validate that the solution checks the right relation with error rate
mutable key1 = ConstantArray(10, false);
mutable key2 = key1 w/ 3 <- true;
@ -142,7 +142,7 @@ namespace Quantum.Kata.KeyDistribution {
//////////////////////////////////////////////////////////////////
@Test("QuantumSimulator")
operation T31_Eavesdrop_Test () : Unit {
operation T31_Eavesdrop () : Unit {
using (q = Qubit()) {
// q = 0, Real value: b = rectangular, Input: b = rectangular
let res00 = Eavesdrop(q, false);

Просмотреть файл

@ -63,7 +63,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_ValidMove_Test \n",
"%kata T11_ValidMove \n",
"\n",
"function ValidAliceMove (cells : Int[]) : Bool {\n",
" // ...\n",
@ -90,7 +90,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_ValidMove_Test \n",
"%kata T11_ValidMove \n",
"\n",
"function ValidBobMove (cells : Int[]) : Bool {\n",
" // ...\n",
@ -122,7 +122,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_WinCondition_Test \n",
"%kata T12_WinCondition \n",
"\n",
"function WinCondition (rowIndex : Int, columnIndex : Int, row : Int[], column : Int[]) : Bool {\n",
" // ...\n",
@ -154,7 +154,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T13_ClassicalStrategy_Test \n",
"%kata T13_ClassicalStrategy \n",
"\n",
"function AliceClassical (rowIndex : Int) : Int[] {\n",
" // ...\n",
@ -180,7 +180,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T13_ClassicalStrategy_Test \n",
"%kata T13_ClassicalStrategy \n",
"\n",
"function BobClassical (columnIndex : Int) : Int[] {\n",
" // ...\n",
@ -227,7 +227,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_CreateEntangledState_Test \n",
"%kata T21_CreateEntangledState \n",
"\n",
"operation CreateEntangledState (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -264,7 +264,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_GetMagicObservables_Test \n",
"%kata T22_GetMagicObservables \n",
"\n",
"function GetMagicObservables (rowIndex : Int, columnIndex : Int) : (Int, Pauli[]) {\n",
" // ...\n",
@ -296,7 +296,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T23_ApplyMagicObservables_Test \n",
"%kata T23_ApplyMagicObservables \n",
"\n",
"operation ApplyMagicObservables (observable : (Int, Pauli[]), qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -336,7 +336,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T24_MeasureObservables_Test \n",
"%kata T24_MeasureObservables \n",
"\n",
"operation MeasureObservable (observable : (Int, Pauli[]), target : Qubit[]) : Result {\n",
" // ...\n",
@ -382,7 +382,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T25_MeasureOperator_Test \n",
"%kata T25_MeasureOperator \n",
"\n",
"operation MeasureOperator (op : (Qubit[] => Unit is Ctl), target : Qubit[]) : Result {\n",
" // ...\n",
@ -430,7 +430,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T26_QuantumStrategy_Test \n",
"%kata T26_QuantumStrategy \n",
"\n",
"operation AliceQuantum (rowIndex : Int, qs : Qubit[]) : Int[] {\n",
" // ...\n",
@ -460,7 +460,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T26_QuantumStrategy_Test \n",
"%kata T26_QuantumStrategy \n",
"\n",
"operation BobQuantum (columnIndex : Int, qs : Qubit[]) : Int[] {\n",
" // ...\n",
@ -493,7 +493,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T27_PlayQuantumMagicSquare_Test \n",
"%kata T27_PlayQuantumMagicSquare \n",
"\n",
"operation PlayQuantumMagicSquare (askAlice : (Qubit[] => Int[]), askBob : (Qubit[] => Int[])) : (Int[], Int[]) {\n",
" // ...\n",

Просмотреть файл

@ -243,7 +243,7 @@ namespace Quantum.Kata.MagicSquareGame {
// Goal:
// Use your classical and quantum magic square strategies from tasks 1.3 and 2.6 to
// verify their probabilities of winning. Can you make the classical strategy lose?
operation MagicSquare_Test () : Unit {
operation MagicSquare () : Unit {
// Hint: You will need to use partial application to use your quantum strategies from task
// 2.6 with PlayQuantumMagicSquare from task 2.7.
@ -252,7 +252,7 @@ namespace Quantum.Kata.MagicSquareGame {
// Hint: Use the DrawMagicSquare function in Tests.qs to see what the magic square looks
// like after Alice and Bob make their moves.
// MagicSquare_Test appears in the list of unit tests for the solution; run it to verify
// MagicSquare appears in the list of unit tests for the solution; run it to verify
// your code.
// ...

Просмотреть файл

@ -22,7 +22,7 @@ namespace Quantum.Kata.MagicSquareGame {
}
@Test("QuantumSimulator")
operation T11_ValidMove_Test () : Unit {
operation T11_ValidMove () : Unit {
// Try all moves with +1 and -1.
for (i in 0..1 <<< 3 - 1) {
let cells = Mapped(SignFromBool, IntAsBoolArray(i, 3));
@ -44,7 +44,7 @@ namespace Quantum.Kata.MagicSquareGame {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T12_WinCondition_Test () : Unit {
operation T12_WinCondition () : Unit {
// Try all moves with +1 and -1.
for (i in 0..1 <<< 3 - 1) {
for (j in 0..1 <<< 3 - 1) {
@ -90,7 +90,7 @@ namespace Quantum.Kata.MagicSquareGame {
}
@Test("QuantumSimulator")
operation T13_ClassicalStrategy_Test() : Unit {
operation T13_ClassicalStrategy() : Unit {
let wins = RunTrials(1000, ClassicalRunner);
Fact(wins >= 850, $"The classical strategy implemented is not optimal: win rate {IntAsDouble(wins) / 1000.}");
}
@ -112,7 +112,7 @@ namespace Quantum.Kata.MagicSquareGame {
}
@Test("QuantumSimulator")
operation T21_CreateEntangledState_Test () : Unit {
operation T21_CreateEntangledState () : Unit {
AssertEqualOnZeroState(4, CreateEntangledState, CreateEntangledState_Reference);
}
@ -161,7 +161,7 @@ namespace Quantum.Kata.MagicSquareGame {
}
@Test("QuantumSimulator")
operation T22_GetMagicObservables_Test () : Unit {
operation T22_GetMagicObservables () : Unit {
// Since there can be multiple magic squares with different observables,
// the test checks the listed properties of the return values rather than the values themselves.
for (row in 0..2) {
@ -181,7 +181,7 @@ namespace Quantum.Kata.MagicSquareGame {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T23_ApplyMagicObservables_Test () : Unit {
operation T23_ApplyMagicObservables () : Unit {
// Try all pairs of observables and all signs, and check the unitary equality
for (sign in [-1, 1]) {
for (obs1 in [PauliI, PauliX, PauliY, PauliZ]) {
@ -196,7 +196,7 @@ namespace Quantum.Kata.MagicSquareGame {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T24_MeasureObservables_Test () : Unit {
operation T24_MeasureObservables () : Unit {
using (qs = Qubit[2]) {
for (sign in [-1, 1]) {
for (obs1 in [PauliI, PauliX, PauliY, PauliZ]) {
@ -230,7 +230,7 @@ namespace Quantum.Kata.MagicSquareGame {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T25_MeasureOperator_Test () : Unit {
operation T25_MeasureOperator () : Unit {
using (qs = Qubit[2]) {
for (sign in [-1, 1]) {
for (obs1 in [PauliI, PauliX, PauliY, PauliZ]) {
@ -271,7 +271,7 @@ namespace Quantum.Kata.MagicSquareGame {
}
@Test("QuantumSimulator")
operation T26_QuantumStrategy_Test () : Unit {
operation T26_QuantumStrategy () : Unit {
let N = 1000;
let wins = RunTrials(N, QuantumRunner(PlayQuantumMagicSquare_Reference, _, _));
Fact(wins == N, $"Alice and Bob's quantum strategy is not optimal: win rate {IntAsDouble(wins) / IntAsDouble(N)}");
@ -280,7 +280,7 @@ namespace Quantum.Kata.MagicSquareGame {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T27_PlayQuantumMagicSquare_Test () : Unit {
operation T27_PlayQuantumMagicSquare () : Unit {
let N = 1000;
let wins = RunTrials(N, QuantumRunner(PlayQuantumMagicSquare, _, _));
Message($"Win rate {IntAsDouble(wins) / IntAsDouble(N)}");

Просмотреть файл

@ -43,7 +43,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T101_IsQubitOne_Test \n",
"%kata T101_IsQubitOne \n",
"\n",
"operation IsQubitOne (q : Qubit) : Bool {\n",
" // The operation M will measure a qubit in the Z basis (|0⟩ and |1⟩ basis)\n",
@ -82,7 +82,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T102_InitializeQubit_Test \n",
"%kata T102_InitializeQubit \n",
"\n",
"operation InitializeQubit (q : Qubit) : Unit {\n",
" // ...\n",
@ -113,7 +113,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T103_IsQubitPlus_Test \n",
"%kata T103_IsQubitPlus \n",
"\n",
"operation IsQubitPlus (q : Qubit) : Bool {\n",
" // ...\n",
@ -147,7 +147,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T104_IsQubitA_Test\n",
"%kata T104_IsQubitA\n",
"\n",
"operation IsQubitA (alpha : Double, q : Qubit) : Bool {\n",
" // ...\n",
@ -178,7 +178,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T105_ZeroZeroOrOneOne_Test\n",
"%kata T105_ZeroZeroOrOneOne\n",
"\n",
"operation ZeroZeroOrOneOne (qs : Qubit[]) : Int {\n",
" // ...\n",
@ -218,7 +218,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T106_BasisStateMeasurement_Test\n",
"%kata T106_BasisStateMeasurement\n",
"\n",
"operation BasisStateMeasurement (qs : Qubit[]) : Int {\n",
" // ...\n",
@ -261,7 +261,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T107_TwoBitstringsMeasurement_Test\n",
"%kata T107_TwoBitstringsMeasurement\n",
"\n",
"operation TwoBitstringsMeasurement (qs : Qubit[], bits1 : Bool[], bits2 : Bool[]) : Int {\n",
" // ...\n",
@ -311,7 +311,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T108_SuperpositionOneMeasurement_Test\n",
"%kata T108_SuperpositionOneMeasurement\n",
"\n",
"operation SuperpositionOneMeasurement (qs : Qubit[], bits1 : Bool[][], bits2 : Bool[][]) : Int {\n",
" // ...\n",
@ -357,7 +357,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T109_SuperpositionMeasurement_Test\n",
"%kata T109_SuperpositionMeasurement\n",
"\n",
"operation SuperpositionMeasurement (qs : Qubit[], bits1 : Bool[][], bits2 : Bool[][]) : Int {\n",
" // ...\n",
@ -393,7 +393,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T110_AllZerosOrWState_Test\n",
"%kata T110_AllZerosOrWState\n",
"\n",
"operation AllZerosOrWState (qs : Qubit[]) : Int {\n",
" // ...\n",
@ -429,7 +429,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T111_GHZOrWState_Test\n",
"%kata T111_GHZOrWState\n",
"\n",
"operation GHZOrWState (qs : Qubit[]) : Int {\n",
" // ...\n",
@ -467,7 +467,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T112_BellState_Test\n",
"%kata T112_BellState\n",
"\n",
"operation BellState (qs : Qubit[]) : Int {\n",
" // ...\n",
@ -505,7 +505,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T113_TwoQubitState_Test\n",
"%kata T113_TwoQubitState\n",
"\n",
"operation TwoQubitState (qs : Qubit[]) : Int {\n",
" // ...\n",
@ -543,7 +543,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T114_TwoQubitStatePartTwo_Test\n",
"%kata T114_TwoQubitStatePartTwo\n",
"\n",
"operation TwoQubitStatePartTwo (qs : Qubit[]) : Int {\n",
" // ...\n",
@ -581,7 +581,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T115_ThreeQubitMeasurement_Test\n",
"%kata T115_ThreeQubitMeasurement\n",
"\n",
"operation ThreeQubitMeasurement (qs : Qubit[]) : Int {\n",
" // ...\n",
@ -636,7 +636,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T201_IsQubitZeroOrPlus_Test\n",
"%kata T201_IsQubitZeroOrPlus\n",
"\n",
"operation IsQubitPlusOrZero (q : Qubit) : Bool {\n",
" // ...\n",
@ -689,7 +689,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T202_IsQubitZeroOrPlusSimpleUSD_Test\n",
"%kata T202_IsQubitZeroOrPlusSimpleUSD\n",
"\n",
"operation IsQubitPlusZeroOrInconclusiveSimpleUSD (q : Qubit) : Int {\n",
" // ...\n",
@ -734,7 +734,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T203_IsQubitNotInABC_Test\n",
"%kata T203_IsQubitNotInABC\n",
"\n",
"operation IsQubitNotInABC (q : Qubit) : Int {\n",
" // ...\n",

Просмотреть файл

@ -42,7 +42,7 @@ namespace Quantum.Kata.Measurements {
// equals One - either directly or using library function IsResultOne.
//
// Replace the returned expression with (M(q) == One).
// Then rebuild the project and rerun the tests - T101_IsQubitOne_Test should now pass!
// Then rebuild the project and rerun the tests - T101_IsQubitOne should now pass!
return false;
}

Просмотреть файл

@ -71,14 +71,14 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T101_IsQubitOne_Test () : Unit {
operation T101_IsQubitOne () : Unit {
DistinguishTwoStates_OneQubit(StatePrep_IsQubitOne, IsQubitOne, ["|0⟩", "|1⟩"]);
}
// ------------------------------------------------------
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T102_InitializeQubit_Test () : Unit {
operation T102_InitializeQubit () : Unit {
using (q = Qubit()) {
for (i in 0 .. 36) {
let alpha = ((2.0 * PI()) * IntAsDouble(i)) / 36.0;
@ -107,7 +107,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T103_IsQubitPlus_Test () : Unit {
operation T103_IsQubitPlus () : Unit {
DistinguishTwoStates_OneQubit(StatePrep_IsQubitPlus, IsQubitPlus, ["|-⟩", "|+⟩"]);
}
@ -127,7 +127,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T104_IsQubitA_Test () : Unit {
operation T104_IsQubitA () : Unit {
// cross-test
// alpha = 0.0 or PI() => !isQubitOne
// alpha = PI() / 2.0 => isQubitOne
@ -224,7 +224,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T105_ZeroZeroOrOneOne_Test () : Unit {
operation T105_ZeroZeroOrOneOne () : Unit {
DistinguishStates_MultiQubit(2, 2, StatePrep_ZeroZeroOrOneOne, ZeroZeroOrOneOne, 0, ["|00⟩", "|11⟩"]);
}
@ -244,7 +244,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T106_BasisStateMeasurement_Test () : Unit {
operation T106_BasisStateMeasurement () : Unit {
DistinguishStates_MultiQubit(2, 4, StatePrep_BasisStateMeasurement, BasisStateMeasurement, 0, ["|00⟩", "|01⟩", "|10⟩", "|11⟩"]);
}
@ -282,7 +282,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T107_TwoBitstringsMeasurement_Test () : Unit {
operation T107_TwoBitstringsMeasurement () : Unit {
mutable b1 = [false, true];
mutable b2 = [true, false];
CheckTwoBitstringsMeasurement(b1, b2);
@ -407,7 +407,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T108_SuperpositionOneMeasurement_Test () : Unit {
operation T108_SuperpositionOneMeasurement () : Unit {
// note that bit strings in the comments (big endian) are the reverse of the bit strings passed to the solutions (little endian)
CheckSuperpositionBitstringsOneMeasurement(2, [2], // [10]
[1]); // [01]
@ -449,7 +449,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T109_SuperpositionMeasurement_Test () : Unit {
operation T109_SuperpositionMeasurement () : Unit {
// note that bit strings in the comments (big endian) are the reverse of the bit strings passed to the solutions (little endian)
CheckSuperpositionBitstringsMeasurement(2, [2], // [10]
[1]); // [01]
@ -510,7 +510,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T110_AllZerosOrWState_Test () : Unit {
operation T110_AllZerosOrWState () : Unit {
for (i in 2 .. 6) {
DistinguishStates_MultiQubit(i, 2, StatePrep_AllZerosOrWState, AllZerosOrWState, 0, ["|0...0⟩", "|W⟩"]);
@ -539,7 +539,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T111_GHZOrWState_Test () : Unit {
operation T111_GHZOrWState () : Unit {
for (i in 2 .. 6) {
DistinguishStates_MultiQubit(i, 2, StatePrep_GHZOrWState, GHZOrWState, 0, ["|GHZ⟩", "|W⟩"]);
}
@ -566,7 +566,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T112_BellState_Test () : Unit {
operation T112_BellState () : Unit {
DistinguishStates_MultiQubit(2, 4, StatePrep_BellState, BellState, 0, ["|Φ⁺⟩ = (|00⟩ + |11⟩) / sqrt(2)",
"|Φ⁻⟩ = (|00⟩ - |11⟩) / sqrt(2)",
"|Ψ⁺⟩ = (|01⟩ + |10⟩) / sqrt(2)",
@ -586,7 +586,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T113_TwoQubitState_Test () : Unit {
operation T113_TwoQubitState () : Unit {
DistinguishStates_MultiQubit(2, 4, StatePrep_TwoQubitState, TwoQubitState, 0, ["(|00⟩ + |01⟩ + |10⟩ + |11⟩) / 2",
"(|00⟩ - |01⟩ + |10⟩ - |11⟩) / 2",
"(|00⟩ + |01⟩ - |10⟩ - |11⟩) / 2",
@ -616,7 +616,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T114_TwoQubitStatePartTwo_Test () : Unit {
operation T114_TwoQubitStatePartTwo () : Unit {
DistinguishStates_MultiQubit(2, 4, StatePrep_TwoQubitStatePartTwo, TwoQubitStatePartTwo, 0, ["(+|00⟩ - |01⟩ - |10⟩ - |11⟩) / 2",
"(-|00⟩ + |01⟩ - |10⟩ - |11⟩) / 2",
"(-|00⟩ - |01⟩ + |10⟩ - |11⟩) / 2",
@ -641,7 +641,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T115_ThreeQubitMeasurement_Test () : Unit {
operation T115_ThreeQubitMeasurement () : Unit {
DistinguishStates_MultiQubit(3, 2, StatePrep_ThreeQubitMeasurement, ThreeQubitMeasurement, 0,
["1/sqrt(3) (|100⟩ + ω |010⟩ + ω² |001⟩)",
"1/sqrt(3) (|100⟩ + ω² |010⟩ + ω |001⟩)"]);
@ -692,7 +692,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T201_IsQubitZeroOrPlus_Test () : Unit {
operation T201_IsQubitZeroOrPlus () : Unit {
DistinguishStates_MultiQubit_Threshold(1, 2, 0.8, StatePrep_IsQubitZeroOrPlus, IsQubitPlusOrZero);
}
@ -768,7 +768,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T202_IsQubitZeroOrPlusSimpleUSD_Test () : Unit {
operation T202_IsQubitZeroOrPlusSimpleUSD () : Unit {
USD_DistinguishStates_MultiQubit_Threshold(1, 2, 0.8, 0.1, StatePrep_IsQubitZeroOrPlus, IsQubitPlusZeroOrInconclusiveSimpleUSD);
}
@ -829,7 +829,7 @@ namespace Quantum.Kata.Measurements {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T203_IsQubitNotInABC_Test () : Unit {
operation T203_IsQubitNotInABC () : Unit {
ABC_DistinguishStates_MultiQubit_Threshold(1, 3, StatePrep_IsQubitNotInABC, IsQubitNotInABC);
}
}

Просмотреть файл

@ -58,7 +58,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T101_IsQubitOne_Test \n",
"%kata T101_IsQubitOne \n",
"\n",
"operation IsQubitOne (q : Qubit) : Bool {\n",
" return M(q) == One;\n",
@ -102,7 +102,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T102_InitializeQubit_Test \n",
"%kata T102_InitializeQubit \n",
"\n",
"operation InitializeQubit (q : Qubit) : Unit {\n",
" if (M(q) == One) {\n",
@ -151,7 +151,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T103_IsQubitPlus_Test \n",
"%kata T103_IsQubitPlus \n",
"\n",
"operation IsQubitPlus (q : Qubit) : Bool {\n",
" H(q);\n",
@ -174,7 +174,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T103_IsQubitPlus_Test \n",
"%kata T103_IsQubitPlus \n",
"\n",
"operation IsQubitPlus (q : Qubit) : Bool {\n",
" return Measure([PauliX], [q]) == Zero;\n",
@ -227,7 +227,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T104_IsQubitA_Test\n",
"%kata T104_IsQubitA\n",
"\n",
"operation IsQubitA (alpha : Double, q : Qubit) : Bool {\n",
" Ry(-2.0 * alpha, q);\n",
@ -271,7 +271,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T105_ZeroZeroOrOneOne_Test\n",
"%kata T105_ZeroZeroOrOneOne\n",
"\n",
"operation ZeroZeroOrOneOne (qs : Qubit[]) : Int {\n",
" return M(qs[0]) == One ? 1 | 0;\n",
@ -328,7 +328,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T106_BasisStateMeasurement_Test\n",
"%kata T106_BasisStateMeasurement\n",
"\n",
"operation BasisStateMeasurement (qs : Qubit[]) : Int {\n",
" // Measurement on the first qubit gives the higher bit of the answer, on the second - the lower\n",
@ -413,7 +413,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T107_TwoBitstringsMeasurement_Test\n",
"%kata T107_TwoBitstringsMeasurement\n",
"\n",
"operation TwoBitstringsMeasurement (qs : Qubit[], bits1 : Bool[], bits2 : Bool[]) : Int {\n",
" // find the first index at which the bit strings are different and measure it\n",
@ -524,7 +524,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T108_SuperpositionOneMeasurement_Test\n",
"%kata T108_SuperpositionOneMeasurement\n",
"\n",
"open Microsoft.Quantum.Convert;\n",
"\n",
@ -598,7 +598,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T109_SuperpositionMeasurement_Test\n",
"%kata T109_SuperpositionMeasurement\n",
"\n",
"open Microsoft.Quantum.Convert;\n",
"open Microsoft.Quantum.Measurement;\n",
@ -656,7 +656,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T110_AllZerosOrWState_Test\n",
"%kata T110_AllZerosOrWState\n",
"\n",
"operation AllZerosOrWState (qs : Qubit[]) : Int {\n",
" mutable countOnes = 0;\n",
@ -684,7 +684,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T110_AllZerosOrWState_Test\n",
"%kata T110_AllZerosOrWState\n",
"\n",
"open Microsoft.Quantum.Convert;\n",
"open Microsoft.Quantum.Measurement;\n",
@ -736,7 +736,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T111_GHZOrWState_Test\n",
"%kata T111_GHZOrWState\n",
"\n",
"operation GHZOrWState (qs : Qubit[]) : Int {\n",
" mutable countOnes = 0;\n",
@ -837,7 +837,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T112_BellState_Test\n",
"%kata T112_BellState\n",
"\n",
"operation BellState (qs : Qubit[]) : Int {\n",
" CNOT(qs[0], qs[1]);\n",
@ -909,7 +909,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T113_TwoQubitState_Test\n",
"%kata T113_TwoQubitState\n",
"\n",
"operation TwoQubitState (qs : Qubit[]) : Int {\n",
" H(qs[0]);\n",
@ -997,7 +997,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T114_TwoQubitStatePartTwo_Test\n",
"%kata T114_TwoQubitStatePartTwo\n",
"\n",
"operation TwoQubitStatePartTwo (qs : Qubit[]) : Int {\n",
" H(qs[1]);\n",
@ -1101,7 +1101,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T115_ThreeQubitMeasurement_Test\n",
"%kata T115_ThreeQubitMeasurement\n",
"\n",
"open Microsoft.Quantum.Math;\n",
"open Microsoft.Quantum.Measurement;\n",

Просмотреть файл

@ -82,7 +82,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T201_IsQubitZeroOrPlus_Test\n",
"%kata T201_IsQubitZeroOrPlus\n",
"\n",
"open Microsoft.Quantum.Math;\n",
"\n",
@ -158,7 +158,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T202_IsQubitZeroOrPlusSimpleUSD_Test\n",
"%kata T202_IsQubitZeroOrPlusSimpleUSD\n",
"\n",
"open Microsoft.Quantum.Random;\n",
"\n",
@ -316,7 +316,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T203_IsQubitNotInABC_Test\n",
"%kata T203_IsQubitNotInABC\n",
"\n",
"open Microsoft.Quantum.Math;\n",
"open Microsoft.Quantum.Measurement;\n",

Просмотреть файл

@ -53,7 +53,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_Eigenstates_ZST_Test \n",
"%kata T11_Eigenstates_ZST \n",
"\n",
"operation Eigenstates_ZST (q : Qubit, state : Int) : Unit is Adj {\n",
" // ...\n",
@ -89,7 +89,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_UnitaryPower_Test \n",
"%kata T12_UnitaryPower \n",
"\n",
"function UnitaryPower (U : (Qubit => Unit is Adj + Ctl), power : Int) : (Qubit => Unit is Adj + Ctl) {\n",
" // ...\n",
@ -145,7 +145,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_QPE_Test \n",
"%kata T14_QPE \n",
"\n",
"operation QPE (U : (Qubit => Unit is Adj + Ctl), P : (Qubit => Unit is Adj), n : Int) : Double {\n",
" // ...\n",
@ -237,7 +237,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_SingleBitPE_Test \n",
"%kata T21_SingleBitPE \n",
"\n",
"operation SingleBitPE (U : (Qubit => Unit is Adj + Ctl), P : (Qubit => Unit is Adj)) : Int {\n",
" // ...\n",
@ -287,7 +287,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_TwoBitPE_Test \n",
"%kata T22_TwoBitPE \n",
"\n",
"operation TwoBitPE (U : (Qubit => Unit is Adj + Ctl), P : (Qubit => Unit is Adj)) : Double {\n",
" // ...\n",

Просмотреть файл

@ -95,7 +95,7 @@ namespace Quantum.Kata.PhaseEstimation {
// Goal: Use your QPE implementation from task 1.4 to run quantum phase estimation
// on several simple unitaries and their eigenstates.
// This task is not covered by a test and allows you to experiment with running the algorithm.
operation T15_E2E_QPE_Test () : Unit {
operation T15_E2E_QPE () : Unit {
// ...
}

Просмотреть файл

@ -35,7 +35,7 @@ namespace T13
}
[Fact]
public void T13_AssertIsEigenstate_Test()
public void T13_AssertIsEigenstate()
{
using (var sim = new CounterSimulator())
{

Просмотреть файл

@ -32,7 +32,7 @@ namespace Quantum.Kata.PhaseEstimation {
}
@Test("QuantumSimulator")
operation T11_Eigenstates_ZST_Test () : Unit {
operation T11_Eigenstates_ZST () : Unit {
for (state in 0 .. 1) {
AssertEqualOnZeroState1(Eigenstates_ZST(_, state), Eigenstates_ZST_Reference(_, state));
}
@ -46,7 +46,7 @@ namespace Quantum.Kata.PhaseEstimation {
}
@Test("QuantumSimulator")
operation T12_UnitaryPower_Test () : Unit {
operation T12_UnitaryPower () : Unit {
for (U in [Z, S, T]) {
for (power in 1 .. 5) {
AssertOperationsEqualReferenced(1, ArrayWrapperOperation1(UnitaryPower(U, power), _),
@ -70,7 +70,7 @@ namespace Quantum.Kata.PhaseEstimation {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T14_QPE_Test () : Unit {
operation T14_QPE () : Unit {
EqualityWithinToleranceFact(QPE(Z, I, 1), 0.0, 0.25);
EqualityWithinToleranceFact(QPE(Z, X, 1), 0.5, 0.25);
@ -101,7 +101,7 @@ namespace Quantum.Kata.PhaseEstimation {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T21_SingleBitPE_Test () : Unit {
operation T21_SingleBitPE () : Unit {
Test1BitPEOnOnePair(Z, I, +1);
Test1BitPEOnOnePair(Z, X, -1);
Test1BitPEOnOnePair(X, H, +1);
@ -121,7 +121,7 @@ namespace Quantum.Kata.PhaseEstimation {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T22_TwoBitPE_Test () : Unit {
operation T22_TwoBitPE () : Unit {
Test2BitPEOnOnePair(Z, I, 0.0);
Test2BitPEOnOnePair(Z, X, 0.5);
Test2BitPEOnOnePair(S, X, 0.25);

Просмотреть файл

@ -34,7 +34,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T01_MeasureParity_Test \n",
"%kata T01_MeasureParity \n",
"\n",
"operation MeasureParity (register : Qubit[]) : Result {\n",
" // ...\n",
@ -59,7 +59,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T02_Encode_Test \n",
"%kata T02_Encode \n",
"\n",
"operation Encode (register : Qubit[]) : Unit {\n",
" // ...\n",
@ -85,7 +85,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T03_DetectErrorOnLeftQubit_Test \n",
"%kata T03_DetectErrorOnLeftQubit \n",
"\n",
"operation DetectErrorOnLeftQubit (register : Qubit[]) : Result {\n",
" // ...\n",
@ -116,7 +116,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T04_CorrectErrorOnLeftQubit_Test\n",
"%kata T04_CorrectErrorOnLeftQubit\n",
"\n",
"operation CorrectErrorOnLeftQubit (register : Qubit[]) : Unit {\n",
" // ...\n",
@ -149,7 +149,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T05_DetectErrorOnAnyQubit_Test\n",
"%kata T05_DetectErrorOnAnyQubit\n",
"\n",
"operation DetectErrorOnAnyQubit (register : Qubit[]) : Int {\n",
" // ...\n",
@ -174,7 +174,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T06_CorrectErrorOnAnyQubit_Test\n",
"%kata T06_CorrectErrorOnAnyQubit\n",
"\n",
"operation CorrectErrorOnAnyQubit (register : Qubit[]) : Unit {\n",
" // ...\n",
@ -207,7 +207,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T07_LogicalX_Test\n",
"%kata T07_LogicalX\n",
"\n",
"operation LogicalX (register : Qubit[]) : Unit {\n",
" // ...\n",
@ -231,7 +231,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T08_LogicalZ_Test\n",
"%kata T08_LogicalZ\n",
"\n",
"operation LogicalZ (register : Qubit[]) : Unit {\n",
" // ...\n",

Просмотреть файл

@ -109,7 +109,7 @@ namespace Quantum.Kata.QEC_BitFlipCode {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T01_MeasureParity_Test () : Unit {
operation T01_MeasureParity () : Unit {
// test on all basis states
for (bits in 0 .. 7) {
let bitsStr = ToString_Bitmask(bits);
@ -164,7 +164,7 @@ namespace Quantum.Kata.QEC_BitFlipCode {
}
@Test("QuantumSimulator")
operation T02_Encode_Test () : Unit {
operation T02_Encode () : Unit {
for (i in 0 .. 36) {
let alpha = ((2.0 * PI()) * IntAsDouble(i)) / 36.0;
AssertEqualOnZeroState(StatePrep_Rotate(_, alpha), Encode, Encode_Reference);
@ -187,7 +187,7 @@ namespace Quantum.Kata.QEC_BitFlipCode {
}
@Test("QuantumSimulator")
operation T03_DetectErrorOnLeftQubit_Test () : Unit {
operation T03_DetectErrorOnLeftQubit () : Unit {
using (register = Qubit[3]) {
for (i in 0 .. 36) {
let alpha = ((2.0 * PI()) * IntAsDouble(i)) / 36.0;
@ -256,7 +256,7 @@ namespace Quantum.Kata.QEC_BitFlipCode {
}
@Test("QuantumSimulator")
operation T04_CorrectErrorOnLeftQubit_Test () : Unit {
operation T04_CorrectErrorOnLeftQubit () : Unit {
let partialBind = BindErrorCorrectionRound(Encode_Reference, _, NoOp<Qubit[]>, CorrectErrorOnLeftQubit);
let errors = PauliErrors();
@ -271,7 +271,7 @@ namespace Quantum.Kata.QEC_BitFlipCode {
//////////////////////////////////////////////////////////////////////////
@Test("QuantumSimulator")
operation T05_DetectErrorOnAnyQubit_Test () : Unit {
operation T05_DetectErrorOnAnyQubit () : Unit {
let errors = PauliErrors();
using (register = Qubit[3]) {
@ -303,7 +303,7 @@ namespace Quantum.Kata.QEC_BitFlipCode {
//////////////////////////////////////////////////////////////////////////
@Test("QuantumSimulator")
operation T06_CorrectErrorOnAnyQubit_Test () : Unit {
operation T06_CorrectErrorOnAnyQubit () : Unit {
let partialBind = BindErrorCorrectionRound(Encode_Reference, _, NoOp<Qubit[]>, CorrectErrorOnAnyQubit);
let errors = PauliErrors();
@ -320,7 +320,7 @@ namespace Quantum.Kata.QEC_BitFlipCode {
//////////////////////////////////////////////////////////////////////////
@Test("QuantumSimulator")
operation T07_LogicalX_Test () : Unit {
operation T07_LogicalX () : Unit {
let partialBind = BindErrorCorrectionRound(Encode_Reference, _, LogicalX, CorrectErrorOnAnyQubit_Reference);
let errors = PauliErrors();
@ -337,7 +337,7 @@ namespace Quantum.Kata.QEC_BitFlipCode {
//////////////////////////////////////////////////////////////////////////
@Test("QuantumSimulator")
operation T08_LogicalZ_Test () : Unit {
operation T08_LogicalZ () : Unit {
let partialBind = BindErrorCorrectionRound(Encode_Reference, _, LogicalZ, CorrectErrorOnAnyQubit_Reference);
let errors = PauliErrors();

Просмотреть файл

@ -53,7 +53,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_OneQubitQFT_Test \n",
"%kata T11_OneQubitQFT \n",
"\n",
"operation OneQubitQFT (q : Qubit) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -86,7 +86,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_Rotation_Test \n",
"%kata T12_Rotation \n",
"\n",
"operation Rotation (q : Qubit, k : Int) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -119,7 +119,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T13_BinaryFractionClassical_Test \n",
"%kata T13_BinaryFractionClassical \n",
"\n",
"operation BinaryFractionClassical (q : Qubit, j : Int[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -156,7 +156,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_BinaryFractionQuantum_Test \n",
"%kata T14_BinaryFractionQuantum \n",
"\n",
"operation BinaryFractionQuantum (q : Qubit, jRegister : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -194,7 +194,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T15_BinaryFractionQuantumInPlace_Test \n",
"%kata T15_BinaryFractionQuantumInPlace \n",
"\n",
"operation BinaryFractionQuantumInPlace (register : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -222,7 +222,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T16_ReverseRegister_Test \n",
"%kata T16_ReverseRegister \n",
"\n",
"operation ReverseRegister (register : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -271,7 +271,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T17_QuantumFourierTransform_Test \n",
"%kata T17_QuantumFourierTransform \n",
"\n",
"operation QuantumFourierTransform (register : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -306,7 +306,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T18_InverseQFT_Test \n",
"%kata T18_InverseQFT \n",
"\n",
"operation InverseQFT (register : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -346,7 +346,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_PrepareEqualSuperposition_Test \n",
"%kata T21_PrepareEqualSuperposition \n",
"\n",
"operation PrepareEqualSuperposition (register : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -389,7 +389,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_PreparePeriodicState_Test \n",
"%kata T22_PreparePeriodicState \n",
"\n",
"operation PreparePeriodicState (register : Qubit[], F : Int) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -426,7 +426,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T23_PrepareAlternatingState_Test \n",
"%kata T23_PrepareAlternatingState \n",
"\n",
"operation PrepareAlternatingState (register : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -461,7 +461,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T24_PrepareEqualSuperpositionOfEvenStates_Test \n",
"%kata T24_PrepareEqualSuperpositionOfEvenStates \n",
"\n",
"operation PrepareEqualSuperpositionOfEvenStates (register : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -496,7 +496,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T25_PrepareSquareWaveSignal_Test \n",
"%kata T25_PrepareSquareWaveSignal \n",
"\n",
"operation PrepareSquareWaveSignal (register : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -525,7 +525,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T26_Frequency_Test \n",
"%kata T26_Frequency \n",
"\n",
"operation Frequency (register : Qubit[]) : Int {\n",
" // ...\n",
@ -569,7 +569,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T31_QFTPower_Test\n",
"%kata T31_QFTPower\n",
"\n",
"operation QFTPower (P : Int, inputRegister : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -599,7 +599,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T32_QFTRoot_Test\n",
"%kata T32_QFTRoot\n",
"\n",
"operation QFTRoot (P : Int, inputRegister : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",

Просмотреть файл

@ -28,7 +28,7 @@ namespace Quantum.Kata.QFT {
}
@Test("QuantumSimulator")
operation T11_OneQubitQFT_Test () : Unit {
operation T11_OneQubitQFT () : Unit {
AssertOperationsEqualReferenced(2, ArrayWrapperControlledOperation(OneQubitQFT, _),
ArrayWrapperControlledOperation(OneQubitQFT_Reference, _));
}
@ -36,7 +36,7 @@ namespace Quantum.Kata.QFT {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T12_Rotation_Test () : Unit {
operation T12_Rotation () : Unit {
// several hardcoded tests for small values of k
// k = 0: α |0⟩ + β · exp(2πi) |1⟩ = α |0⟩ + β |1⟩ - identity
AssertOperationsEqualReferenced(2, ArrayWrapperControlledOperation(Rotation(_, 0), _),
@ -72,7 +72,7 @@ namespace Quantum.Kata.QFT {
}
@Test("QuantumSimulator")
operation T13_BinaryFractionClassical_Test () : Unit {
operation T13_BinaryFractionClassical () : Unit {
for (n in 1 .. 5) {
for (exponent in 0 .. (1 <<< n) - 1) {
let bits = IntAsIntArray(exponent, n);
@ -94,7 +94,7 @@ namespace Quantum.Kata.QFT {
}
@Test("QuantumSimulator")
operation T14_BinaryFractionQuantum_Test () : Unit {
operation T14_BinaryFractionQuantum () : Unit {
for (n in 1 .. 5) {
AssertOperationsEqualReferenced(n + 2, Task14InputWrapper(BinaryFractionQuantum, _),
Task14InputWrapper(BinaryFractionQuantum_Reference, _));
@ -104,7 +104,7 @@ namespace Quantum.Kata.QFT {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T15_BinaryFractionQuantumInPlace_Test () : Unit {
operation T15_BinaryFractionQuantumInPlace () : Unit {
for (n in 1 .. 6) {
AssertOperationsEqualReferenced(n, BinaryFractionQuantumInPlace,
BinaryFractionQuantumInPlace_Reference);
@ -114,7 +114,7 @@ namespace Quantum.Kata.QFT {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T16_ReverseRegister_Test () : Unit {
operation T16_ReverseRegister () : Unit {
for (n in 1 .. 6) {
AssertOperationsEqualReferenced(n, ReverseRegister,
ReverseRegister_Reference);
@ -134,7 +134,7 @@ namespace Quantum.Kata.QFT {
}
@Test("QuantumSimulator")
operation T17_QuantumFourierTransform_Test () : Unit {
operation T17_QuantumFourierTransform () : Unit {
AssertOperationsEqualReferenced(1, QuantumFourierTransform, HWrapper);
for (n in 1 .. 5) {
@ -148,7 +148,7 @@ namespace Quantum.Kata.QFT {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T18_InverseQFT_Test () : Unit {
operation T18_InverseQFT () : Unit {
AssertOperationsEqualReferenced(1, InverseQFT, HWrapper);
for (n in 1 .. 5) {
@ -180,7 +180,7 @@ namespace Quantum.Kata.QFT {
}
@Test("QuantumSimulator")
operation T21_PrepareEqualSuperposition_Test () : Unit {
operation T21_PrepareEqualSuperposition () : Unit {
for (N in 1 .. 5) {
AssertEqualOnZeroState(N, PrepareEqualSuperposition, PrepareEqualSuperposition_Reference);
}
@ -189,7 +189,7 @@ namespace Quantum.Kata.QFT {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T22_PreparePeriodicState_Test () : Unit {
operation T22_PreparePeriodicState () : Unit {
for (N in 1 .. 5) {
// cross-test: for F = 0 it's the same as equal superposition of states
AssertEqualOnZeroState(N, PreparePeriodicState(_, 0), PrepareEqualSuperposition_Reference);
@ -203,7 +203,7 @@ namespace Quantum.Kata.QFT {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T23_PrepareAlternatingState_Test () : Unit {
operation T23_PrepareAlternatingState () : Unit {
for (N in 1 .. 5) {
AssertEqualOnZeroState(N, PrepareAlternatingState, PrepareAlternatingState_Reference);
}
@ -216,7 +216,7 @@ namespace Quantum.Kata.QFT {
}
@Test("QuantumSimulator")
operation T24_PrepareEqualSuperpositionOfEvenStates_Test () : Unit {
operation T24_PrepareEqualSuperpositionOfEvenStates () : Unit {
for (N in 1 .. 5) {
// cross-test: we already know how to prepare a superposition of even states
AssertEqualOnZeroState(N, ApplyHToMostWrapper, PrepareEqualSuperpositionOfEvenStates_Reference);
@ -227,7 +227,7 @@ namespace Quantum.Kata.QFT {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T25_PrepareSquareWaveSignal_Test () : Unit {
operation T25_PrepareSquareWaveSignal () : Unit {
for (N in 2 .. 5) {
AssertEqualOnZeroState(N, PrepareSquareWaveSignal, PrepareSquareWaveSignal_Reference);
}
@ -236,7 +236,7 @@ namespace Quantum.Kata.QFT {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T26_Frequency_Test () : Unit {
operation T26_Frequency () : Unit {
for (N in 2 .. 5) {
using (register = Qubit[N]) {
for (F in 0 .. (1 <<< N - 1)) {
@ -266,7 +266,7 @@ namespace Quantum.Kata.QFT {
}
@Test("QuantumSimulator")
operation T31_QFTPower_Test () : Unit {
operation T31_QFTPower () : Unit {
// small tests: check correctness of our approach on small-ish powers on 4-qubit register
for (p in 0 .. 20) {
let testOp = QFTPower_Reference(p, _);
@ -287,7 +287,7 @@ namespace Quantum.Kata.QFT {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T32_QFTRoot_Test () : Unit {
operation T32_QFTRoot () : Unit {
for (n in 2 .. 8) {
for (p in 2 .. 8) {
let testOp = QFTRoot(p, _);

Просмотреть файл

@ -70,7 +70,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_LowestBitSum_Test\n",
"%kata T11_LowestBitSum\n",
"\n",
"operation LowestBitSum (a : Qubit, b : Qubit, sum : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -109,7 +109,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_LowestBitCarry_Test\n",
"%kata T12_LowestBitCarry\n",
"\n",
"operation LowestBitCarry (a : Qubit, b : Qubit, carry : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -140,7 +140,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T13_OneBitAdder_Test\n",
"%kata T13_OneBitAdder\n",
"\n",
"operation OneBitAdder (a : Qubit, b : Qubit, sum : Qubit, carry : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -169,7 +169,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_HighBitSum_Test\n",
"%kata T14_HighBitSum\n",
"\n",
"operation HighBitSum (a : Qubit, b : Qubit, carryin : Qubit, sum : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -198,7 +198,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T15_HighBitCarry_Test\n",
"%kata T15_HighBitCarry\n",
"\n",
"operation HighBitCarry (a : Qubit, b : Qubit, carryin : Qubit, carryout : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -243,7 +243,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T16_TwoBitAdder_Test\n",
"%kata T16_TwoBitAdder\n",
"\n",
"operation TwoBitAdder (a : Qubit[], b : Qubit[], sum : Qubit[], carry : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -279,7 +279,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T17_ArbitraryAdder_Test\n",
"%kata T17_ArbitraryAdder\n",
"\n",
"operation ArbitraryAdder (a : Qubit[], b : Qubit[], sum : Qubit[], carry : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -320,7 +320,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_LowestBitSumInPlace_Test\n",
"%kata T21_LowestBitSumInPlace\n",
"\n",
"operation LowestBitSumInPlace (a : Qubit, b : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -365,7 +365,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_OneBitAdderInPlace_Test\n",
"%kata T22_OneBitAdderInPlace\n",
"\n",
"operation OneBitAdderInPlace (a : Qubit, b : Qubit, carry : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -396,7 +396,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T23_HighBitSumInPlace_Test\n",
"%kata T23_HighBitSumInPlace\n",
"\n",
"operation HighBitSumInPlace (a : Qubit, b : Qubit, carryin : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -428,7 +428,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T24_TwoBitAdderInPlace_Test\n",
"%kata T24_TwoBitAdderInPlace\n",
"\n",
"operation TwoBitAdderInPlace (a : Qubit[], b : Qubit[], carry : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -460,7 +460,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T25_ArbitraryAdderInPlace_Test\n",
"%kata T25_ArbitraryAdderInPlace\n",
"\n",
"operation ArbitraryAdderInPlace (a : Qubit[], b : Qubit[], carry : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -507,7 +507,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T31_Majority_Test\n",
"%kata T31_Majority\n",
"\n",
"operation Majority (a : Qubit, b : Qubit, c : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -539,7 +539,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T32_UnMajorityAdd_Test\n",
"%kata T32_UnMajorityAdd\n",
"\n",
"operation UnMajorityAdd (a : Qubit, b : Qubit, c : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -573,7 +573,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T33_OneBitMajUmaAdder_Test\n",
"%kata T33_OneBitMajUmaAdder\n",
"\n",
"operation OneBitMajUmaAdder (a : Qubit, b : Qubit, carry : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -607,7 +607,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T34_TwoBitMajUmaAdder_Test\n",
"%kata T34_TwoBitMajUmaAdder\n",
"\n",
"operation TwoBitMajUmaAdder (a : Qubit[], b : Qubit[], carry : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -635,7 +635,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T35_ArbitraryMajUmaAdder_Test\n",
"%kata T35_ArbitraryMajUmaAdder\n",
"\n",
"operation ArbitraryMajUmaAdder (a : Qubit[], b : Qubit[], carry : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -683,7 +683,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T41_Subtractor_Test\n",
"%kata T41_Subtractor\n",
"\n",
"operation Subtractor (a : Qubit[], b : Qubit[], borrow : Qubit) : Unit is Adj {\n",
" // ...\n",

Просмотреть файл

@ -169,7 +169,7 @@ namespace Quantum.Kata.RippleCarryAdder {
}
@Test("QuantumSimulator")
operation T11_LowestBitSum_Test () : Unit {
operation T11_LowestBitSum () : Unit {
let testOp = QubitArrayOperationWrapper3(LowestBitSum, _);
let refOp = QubitArrayOperationWrapper3(LowestBitSum_Reference, _);
@ -183,7 +183,7 @@ namespace Quantum.Kata.RippleCarryAdder {
}
@Test("QuantumSimulator")
operation T12_LowestBitCarry_Test () : Unit {
operation T12_LowestBitCarry () : Unit {
let testOp = QubitArrayOperationWrapper3(LowestBitCarry, _);
let refOp = QubitArrayOperationWrapper3(LowestBitCarry_Reference, _);
@ -193,7 +193,7 @@ namespace Quantum.Kata.RippleCarryAdder {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T13_OneBitAdder_Test () : Unit {
operation T13_OneBitAdder () : Unit {
let testOp = QubitArrayOperationWrapper4(OneBitAdder, _);
let refOp = QubitArrayOperationWrapper4(OneBitAdder_Reference, _);
@ -207,7 +207,7 @@ namespace Quantum.Kata.RippleCarryAdder {
}
@Test("QuantumSimulator")
operation T14_HighBitSum_Test () : Unit {
operation T14_HighBitSum () : Unit {
let testOp = QubitArrayOperationWrapper4(HighBitSum, _);
let refOp = QubitArrayOperationWrapper4(HighBitSum_Reference, _);
@ -221,7 +221,7 @@ namespace Quantum.Kata.RippleCarryAdder {
}
@Test("QuantumSimulator")
operation T15_HighBitCarry_Test () : Unit {
operation T15_HighBitCarry () : Unit {
let testOp = QubitArrayOperationWrapper4(HighBitCarry, _);
let refOp = QubitArrayOperationWrapper4(HighBitCarry_Reference, _);
@ -231,7 +231,7 @@ namespace Quantum.Kata.RippleCarryAdder {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T16_TwoBitAdder_Test () : Unit {
operation T16_TwoBitAdder () : Unit {
let testOp = QubitArrayAdderWrapper(2, TwoBitAdder, _);
let refOp = QubitArrayAdderWrapper(2, TwoBitAdder_Reference, _);
@ -241,7 +241,7 @@ namespace Quantum.Kata.RippleCarryAdder {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T17_ArbitraryAdder_Test () : Unit {
operation T17_ArbitraryAdder () : Unit {
// 4 bits seems reasonable - any more than that will take forever
for (nQubitsInRegister in 1 .. 4) {
let testOp1 = QubitArrayAdderWrapper(nQubitsInRegister, ArbitraryAdder, _);
@ -268,7 +268,7 @@ namespace Quantum.Kata.RippleCarryAdder {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T21_LowestBitSumInPlace_Test () : Unit {
operation T21_LowestBitSumInPlace () : Unit {
let testOp = QubitArrayOperationWrapper2(LowestBitSumInPlace, _);
let refOp = QubitArrayOperationWrapper2(LowestBitSumInPlace_Reference, _);
@ -278,7 +278,7 @@ namespace Quantum.Kata.RippleCarryAdder {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T22_OneBitAdderInPlace_Test () : Unit {
operation T22_OneBitAdderInPlace () : Unit {
let testOp = QubitArrayOperationWrapper3(OneBitAdderInPlace, _);
let refOp = QubitArrayOperationWrapper3(OneBitAdderInPlace_Reference, _);
@ -288,7 +288,7 @@ namespace Quantum.Kata.RippleCarryAdder {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T23_HighBitSumInPlace_Test () : Unit {
operation T23_HighBitSumInPlace () : Unit {
let testOp = QubitArrayOperationWrapper3(HighBitSumInPlace, _);
let refOp = QubitArrayOperationWrapper3(HighBitSumInPlace_Reference, _);
@ -298,7 +298,7 @@ namespace Quantum.Kata.RippleCarryAdder {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T24_TwoBitAdderInPlace_Test () : Unit {
operation T24_TwoBitAdderInPlace () : Unit {
let testOp = QubitArrayInPlaceAdderWrapper(2, TwoBitAdderInPlace, _);
let refOp = QubitArrayInPlaceAdderWrapper(2, TwoBitAdderInPlace_Reference, _);
@ -308,7 +308,7 @@ namespace Quantum.Kata.RippleCarryAdder {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T25_ArbitraryAdderInPlace_Test () : Unit {
operation T25_ArbitraryAdderInPlace () : Unit {
for (i in 1 .. 4) {
let testOp = QubitArrayInPlaceAdderWrapper(i, ArbitraryAdderInPlace, _);
let refOp = QubitArrayInPlaceAdderWrapper(i, ArbitraryAdderInPlace_Reference, _);
@ -333,7 +333,7 @@ namespace Quantum.Kata.RippleCarryAdder {
}
@Test("QuantumSimulator")
operation T31_Majority_Test () : Unit {
operation T31_Majority () : Unit {
let testOp = QubitArrayOperationWrapper3(Majority, _);
let refOp = QubitArrayOperationWrapper3(Majority_Reference, _);
@ -353,7 +353,7 @@ namespace Quantum.Kata.RippleCarryAdder {
}
@Test("QuantumSimulator")
operation T32_UnMajorityAdd_Test () : Unit {
operation T32_UnMajorityAdd () : Unit {
let testOp = QubitArrayOperationWrapper3(UnMajorityAdd, _);
let refOp = QubitArrayOperationWrapper3(UnMajorityAdd_Reference, _);
@ -363,7 +363,7 @@ namespace Quantum.Kata.RippleCarryAdder {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T33_OneBitMajUmaAdder_Test () : Unit {
operation T33_OneBitMajUmaAdder () : Unit {
let testOp = QubitArrayOperationWrapper3(OneBitMajUmaAdder, _);
let refOp = QubitArrayOperationWrapper3(OneBitMajUmaAdder_Reference, _);
AssertInPlaceOperationImplementsBinaryFunction(testOp, BinaryAdder(_, 1), 2, 1, 1, 1);
@ -372,7 +372,7 @@ namespace Quantum.Kata.RippleCarryAdder {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T34_TwoBitMajUmaAdder_Test () : Unit {
operation T34_TwoBitMajUmaAdder () : Unit {
// Commented out lines check that this task uses a specific number of Majority and UMA gates
// (as opposed to using an adder from part II).
// Reverted to old test, since operation call counting doesn't work for counting task operations defined in notebooks.
@ -392,7 +392,7 @@ namespace Quantum.Kata.RippleCarryAdder {
// ------------------------------------------------------
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T35_ArbitraryMajUmaAdder_Test () : Unit {
operation T35_ArbitraryMajUmaAdder () : Unit {
// This algorithm is much faster, so a 5 qubit test is feasible
for (i in 1 .. 5) {
let testOp = QubitArrayInPlaceAdderWrapper(i, ArbitraryMajUmaAdder, _);
@ -413,7 +413,7 @@ namespace Quantum.Kata.RippleCarryAdder {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T41_Subtractor_Test () : Unit {
operation T41_Subtractor () : Unit {
for (i in 1 .. 5) {
let testOp = QubitArrayInPlaceAdderWrapper(i, Subtractor, _);
let refOp = QubitArrayInPlaceAdderWrapper(i, Subtractor_Reference, _);

Просмотреть файл

@ -52,14 +52,14 @@ namespace Quantum.Kata.SimonsAlgorithm {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation Q11_Oracle_CountBits_Test () : Unit {
operation Q11_Oracle_CountBits () : Unit {
AssertTwoOraclesAreEqual(1 .. 10, Oracle_CountBits, Oracle_CountBits_Reference);
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation Q12_Oracle_BitwiseRightShift_Test () : Unit {
operation Q12_Oracle_BitwiseRightShift () : Unit {
for (n in 2 .. 6) {
AssertTwoOraclesWithOutputArrAreEqual(n, n, Oracle_BitwiseRightShift, Oracle_BitwiseRightShift_Reference);
}
@ -72,7 +72,7 @@ namespace Quantum.Kata.SimonsAlgorithm {
}
@Test("QuantumSimulator")
operation Q13_Oracle_OperatorOutput_Test () : Unit {
operation Q13_Oracle_OperatorOutput () : Unit {
// cross-tests
// the mask for all 1's should behave the same as Oracle_CountBits
mutable A = ConstantArray(11, 1);
@ -117,7 +117,7 @@ namespace Quantum.Kata.SimonsAlgorithm {
}
@Test("QuantumSimulator")
operation Q14_Oracle_MultidimensionalOperatorOutput_Test () : Unit {
operation Q14_Oracle_MultidimensionalOperatorOutput () : Unit {
mutable A = [[1, 1], [0, 0]];
AssertTwoOraclesWithIntMatrixAreEqual(A, Oracle_MultidimensionalOperatorOutput, Oracle_MultidimensionalOperatorOutput_Reference);
@ -142,7 +142,7 @@ namespace Quantum.Kata.SimonsAlgorithm {
}
@Test("QuantumSimulator")
operation Q21_StatePrep_Test () : Unit {
operation Q21_StatePrep () : Unit {
for (N in 1 .. 10) {
using (qs = Qubit[N]) {
// apply operation that needs to be tested

Просмотреть файл

@ -61,7 +61,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_Oracle_And_Test \n",
"%kata T11_Oracle_And \n",
"\n",
"operation Oracle_And (queryRegister : Qubit[], target : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -107,7 +107,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_Oracle_Or_Test \n",
"%kata T12_Oracle_Or \n",
"\n",
"operation Oracle_Or (queryRegister : Qubit[], target : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -153,7 +153,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T13_Oracle_Xor_Test \n",
"%kata T13_Oracle_Xor \n",
"\n",
"operation Oracle_Xor (queryRegister : Qubit[], target : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -202,7 +202,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_Oracle_AlternatingBits_Test \n",
"%kata T14_Oracle_AlternatingBits \n",
"\n",
"operation Oracle_AlternatingBits (queryRegister : Qubit[], target : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -263,7 +263,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T15_Oracle_SATClause_Test \n",
"%kata T15_Oracle_SATClause \n",
"\n",
"operation Oracle_SATClause (queryRegister : Qubit[], target : Qubit, clause : (Int, Bool)[]) : Unit is Adj {\n",
" // ...\n",
@ -321,7 +321,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T16_Oracle_SAT_Test \n",
"%kata T16_Oracle_SAT \n",
"\n",
"operation Oracle_SAT (queryRegister : Qubit[], target : Qubit, problem : (Int, Bool)[][]) : Unit is Adj {\n",
" // ...\n",
@ -377,7 +377,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_Oracle_Exactly1One_Test \n",
"%kata T21_Oracle_Exactly1One \n",
"\n",
"operation Oracle_Exactly1One (queryRegister : Qubit[], target : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -433,7 +433,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_Oracle_Exactly1SAT_Test \n",
"%kata T22_Oracle_Exactly1SAT \n",
"\n",
"operation Oracle_Exactly1_3SAT (queryRegister : Qubit[], target : Qubit, problem : (Int, Bool)[][]) : Unit is Adj {\n",
" // ...\n",
@ -540,7 +540,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T32_UniversalGroversAlgorithm_Test \n",
"%kata T32_UniversalGroversAlgorithm \n",
"\n",
"operation UniversalGroversAlgorithm (N : Int, oracle : ((Qubit[], Qubit) => Unit is Adj)) : Bool[] {\n",
" // ...\n",

Просмотреть файл

@ -213,7 +213,7 @@ namespace Quantum.Kata.GroversAlgorithm {
// This task is not covered by a test and allows you to experiment with running the algorithm.
//
// If you want to learn Grover's algorithm itself, try doing the GroversAlgorithm kata first.
operation T31_E2E_GroversAlgorithm_Test () : Unit {
operation T31_E2E_GroversAlgorithm () : Unit {
// Hint: Experiment with SAT instances with different number of solutions and the number of algorithm iterations
// to see how the probability of the algorithm finding the correct answer changes depending on these two factors.

Просмотреть файл

@ -70,7 +70,7 @@ namespace Quantum.Kata.GroversAlgorithm {
}
@Test("QuantumSimulator")
operation T11_Oracle_And_Test () : Unit {
operation T11_Oracle_And () : Unit {
AssertOracleImplementsFunction(2, Oracle_And, And);
let testOp = QubitArrayWrapperOperation(Oracle_And, _);
@ -85,7 +85,7 @@ namespace Quantum.Kata.GroversAlgorithm {
}
@Test("QuantumSimulator")
operation T12_Oracle_Or_Test () : Unit {
operation T12_Oracle_Or () : Unit {
AssertOracleImplementsFunction(2, Oracle_Or, Or);
let testOp = QubitArrayWrapperOperation(Oracle_Or, _);
@ -100,7 +100,7 @@ namespace Quantum.Kata.GroversAlgorithm {
}
@Test("QuantumSimulator")
operation T13_Oracle_Xor_Test () : Unit {
operation T13_Oracle_Xor () : Unit {
AssertOracleImplementsFunction(2, Oracle_Xor, Xor);
let testOp = QubitArrayWrapperOperation(Oracle_Xor, _);
@ -120,7 +120,7 @@ namespace Quantum.Kata.GroversAlgorithm {
}
@Test("QuantumSimulator")
operation T14_Oracle_AlternatingBits_Test () : Unit {
operation T14_Oracle_AlternatingBits () : Unit {
let testOp = QubitArrayWrapperOperation(Oracle_AlternatingBits, _);
let refOp = QubitArrayWrapperOperation(Oracle_AlternatingBits_Reference, _);
@ -191,7 +191,7 @@ namespace Quantum.Kata.GroversAlgorithm {
}
@Test("QuantumSimulator")
operation T15_Oracle_SATClause_Test () : Unit {
operation T15_Oracle_SATClause () : Unit {
for (i in 1..10) {
let nVar = DrawRandomInt(3, 7);
let clause = Generate_SAT_Clause(nVar, i);
@ -252,7 +252,7 @@ namespace Quantum.Kata.GroversAlgorithm {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T16_Oracle_SAT_Test () : Unit {
operation T16_Oracle_SAT () : Unit {
// General SAT oracle should be able to implement all 2SAT problems
RunCrossTests(Oracle_SAT);
@ -287,7 +287,7 @@ namespace Quantum.Kata.GroversAlgorithm {
}
@Test("QuantumSimulator")
operation T21_Oracle_Exactly1One_Test () : Unit {
operation T21_Oracle_Exactly1One () : Unit {
AssertOracleImplementsFunction(3, Oracle_Exactly1One, F_Exactly1One);
let testOp = QubitArrayWrapperOperation(Oracle_Exactly1One, _);
@ -320,7 +320,7 @@ namespace Quantum.Kata.GroversAlgorithm {
}
@Test("QuantumSimulator")
operation T22_Oracle_Exactly1SAT_Test () : Unit {
operation T22_Oracle_Exactly1SAT () : Unit {
// General SAT instances for 2..6 variables
for (nVar in 2..6) {
let problem = GenerateSATInstance(nVar, nVar - 1, 3);
@ -350,7 +350,7 @@ namespace Quantum.Kata.GroversAlgorithm {
}
@Test("QuantumSimulator")
operation T32_UniversalGroversAlgorithm_Test () : Unit {
operation T32_UniversalGroversAlgorithm () : Unit {
// AND: 1 solution/4
RunGroverOnOneInstance(2, [[(0, true)], [(1, true)]]);

Просмотреть файл

@ -104,7 +104,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_Oracle_And_Test \n",
"%kata T11_Oracle_And \n",
"\n",
"operation Oracle_And (queryRegister : Qubit[], target : Qubit) : Unit is Adj {\n",
" Controlled X(queryRegister, target); \n",
@ -197,7 +197,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_Oracle_Or_Test \n",
"%kata T12_Oracle_Or \n",
"\n",
"operation Oracle_Or (queryRegister : Qubit[], target : Qubit) : Unit is Adj {\n",
" within {\n",
@ -283,7 +283,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T13_Oracle_Xor_Test \n",
"%kata T13_Oracle_Xor \n",
"\n",
"operation Oracle_Xor (queryRegister : Qubit[], target : Qubit) : Unit is Adj {\n",
" ApplyToEachA(CNOT(_, target), queryRegister); \n",
@ -343,7 +343,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_Oracle_AlternatingBits_Test \n",
"%kata T14_Oracle_AlternatingBits \n",
"\n",
"open Microsoft.Quantum.Arrays;\n",
"\n",
@ -383,7 +383,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_Oracle_AlternatingBits_Test \n",
"%kata T14_Oracle_AlternatingBits \n",
"\n",
"open Microsoft.Quantum.Arrays;\n",
"\n",
@ -489,7 +489,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T15_Oracle_SATClause_Test \n",
"%kata T15_Oracle_SATClause \n",
"\n",
"open Microsoft.Quantum.Arrays;\n",
" \n",
@ -535,7 +535,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T15_Oracle_SATClause_Test \n",
"%kata T15_Oracle_SATClause \n",
"\n",
"open Microsoft.Quantum.Arrays;\n",
" \n",
@ -626,7 +626,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T16_Oracle_SAT_Test \n",
"%kata T16_Oracle_SAT \n",
"\n",
"operation Oracle_SAT (queryRegister : Qubit[], target : Qubit, problem : (Int, Bool)[][]) : Unit is Adj {\n",
" using (auxiliaryRegister = Qubit[Length(problem)]) {\n",
@ -713,7 +713,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_Oracle_Exactly1One_Test \n",
"%kata T21_Oracle_Exactly1One \n",
"\n",
"operation Oracle_Exactly1One (queryRegister : Qubit[], target : Qubit) : Unit is Adj {\n",
" for (i in 0 .. Length(queryRegister) - 1) {\n",
@ -808,7 +808,7 @@
},
"outputs": [],
"source": [
"%kata T22_Oracle_Exactly1SAT_Test \n",
"%kata T22_Oracle_Exactly1SAT \n",
"\n",
"operation Oracle_Exactly1_3SAT (queryRegister : Qubit[], target : Qubit, problem : (Int, Bool)[][]) : Unit is Adj {\n",
" using (auxiliaryRegister = Qubit[Length(problem)]) {\n",
@ -1022,7 +1022,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T32_UniversalGroversAlgorithm_Test \n",
"%kata T32_UniversalGroversAlgorithm \n",
"\n",
"open Microsoft.Quantum.Measurement;\n",
"open Microsoft.Quantum.Convert;\n",

Просмотреть файл

@ -41,7 +41,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T1_CreateEntangledPair_Test\n",
"%kata T1_CreateEntangledPair\n",
"\n",
"operation CreateEntangledPair (q1 : Qubit, q2 : Qubit) : Unit is Adj {\n",
" // ...\n",
@ -83,7 +83,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T2_EncodeMessageInQubit_Test \n",
"%kata T2_EncodeMessageInQubit \n",
"\n",
"open Quantum.Kata.SuperdenseCoding;\n",
"\n",
@ -119,7 +119,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T3_DecodeMessageFromQubits_Test \n",
"%kata T3_DecodeMessageFromQubits \n",
"\n",
"open Quantum.Kata.SuperdenseCoding;\n",
"\n",
@ -147,7 +147,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T4_SuperdenseCodingProtocol_Test\n",
"%kata T4_SuperdenseCodingProtocol\n",
"\n",
"open Quantum.Kata.SuperdenseCoding;\n",
"\n",

Просмотреть файл

@ -15,7 +15,7 @@ namespace Quantum.Kata.SuperdenseCoding {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T1_CreateEntangledPair_Test () : Unit {
operation T1_CreateEntangledPair () : Unit {
using ((q1, q2) = (Qubit(), Qubit())) {
// apply operation that needs to be tested
@ -67,17 +67,17 @@ namespace Quantum.Kata.SuperdenseCoding {
}
@Test("QuantumSimulator")
operation T2_EncodeMessageInQubit_Test () : Unit {
operation T2_EncodeMessageInQubit () : Unit {
TestProtocol(ComposeProtocol(EncodeMessageInQubit, DecodeMessageFromQubits_Reference, _));
}
@Test("QuantumSimulator")
operation T3_DecodeMessageFromQubits_Test () : Unit {
operation T3_DecodeMessageFromQubits () : Unit {
TestProtocol(ComposeProtocol(EncodeMessageInQubit_Reference, DecodeMessageFromQubits, _));
}
@Test("QuantumSimulator")
operation T4_SuperdenseCodingProtocol_Test () : Unit {
operation T4_SuperdenseCodingProtocol () : Unit {
TestProtocol(SuperdenseCodingProtocol);
}

Просмотреть файл

@ -46,7 +46,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T101_PlusState_Test \n",
"%kata T101_PlusState \n",
"\n",
"operation PlusState (q : Qubit) : Unit {\n",
" // Hadamard gate H will convert |0⟩ state to |+⟩ state.\n",
@ -81,7 +81,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T102_MinusState_Test \n",
"%kata T102_MinusState \n",
"\n",
"operation MinusState (q : Qubit) : Unit {\n",
" // ...\n",
@ -112,7 +112,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T103_AllBasisVectors_TwoQubits_Test\n",
"%kata T103_AllBasisVectors_TwoQubits\n",
"\n",
"operation AllBasisVectors_TwoQubits (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -143,7 +143,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T104_AllBasisVectorWithPhaseFlip_TwoQubits_Test\n",
"%kata T104_AllBasisVectorWithPhaseFlip_TwoQubits\n",
"\n",
"operation AllBasisVectorWithPhaseFlip_TwoQubits (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -180,7 +180,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T105_AllBasisVectorsWithPhases_TwoQubits_Test\n",
"%kata T105_AllBasisVectorsWithPhases_TwoQubits\n",
"\n",
"operation AllBasisVectorsWithPhases_TwoQubits (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -213,7 +213,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T106_BellState_Test\n",
"%kata T106_BellState\n",
"\n",
"operation BellState (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -272,7 +272,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T107_AllBellStates_Test\n",
"%kata T107_AllBellStates\n",
"\n",
"operation AllBellStates (qs : Qubit[], index : Int) : Unit {\n",
" // ...\n",
@ -305,7 +305,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T108_GHZ_State_Test\n",
"%kata T108_GHZ_State\n",
"\n",
"operation GHZ_State (qs : Qubit[]) : Unit {\n",
" // You can find N as Length(qs).\n",
@ -345,7 +345,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T109_AllBasisVectorsSuperposition_Test\n",
"%kata T109_AllBasisVectorsSuperposition\n",
"\n",
"operation AllBasisVectorsSuperposition (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -383,7 +383,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T110_EvenOddNumbersSuperposition_Test\n",
"%kata T110_EvenOddNumbersSuperposition\n",
"\n",
"operation EvenOddNumbersSuperposition (qs : Qubit[], isEven : Bool) : Unit {\n",
" // ...\n",
@ -419,7 +419,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T111_ZeroAndBitstringSuperposition_Test\n",
"%kata T111_ZeroAndBitstringSuperposition\n",
"\n",
"operation ZeroAndBitstringSuperposition (qs : Qubit[], bits : Bool[]) : Unit {\n",
" // ...\n",
@ -457,7 +457,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T112_TwoBitstringSuperposition_Test\n",
"%kata T112_TwoBitstringSuperposition\n",
"\n",
"operation TwoBitstringSuperposition (qs : Qubit[], bits1 : Bool[], bits2 : Bool[]) : Unit {\n",
" // ...\n",
@ -499,7 +499,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T113_FourBitstringSuperposition_Test\n",
"%kata T113_FourBitstringSuperposition\n",
"\n",
"operation FourBitstringSuperposition (qs : Qubit[], bits : Bool[][]) : Unit {\n",
" // ...\n",
@ -545,7 +545,7 @@
},
"outputs": [],
"source": [
"%kata T114_AllStatesWithParitySuperposition_Test\n",
"%kata T114_AllStatesWithParitySuperposition\n",
"\n",
"operation AllStatesWithParitySuperposition (qs : Qubit[], parity : Int) : Unit {\n",
" // ...\n",
@ -593,7 +593,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T201_UnequalSuperposition_Test \n",
"%kata T201_UnequalSuperposition \n",
"\n",
"operation UnequalSuperposition (q : Qubit, alpha : Double) : Unit {\n",
" // ...\n",
@ -624,7 +624,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T202_ControlledRotation_Test \n",
"%kata T202_ControlledRotation \n",
"\n",
"operation ControlledRotation (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -661,7 +661,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T203_ThreeStates_TwoQubits_Test\n",
"%kata T203_ThreeStates_TwoQubits\n",
"\n",
"operation ThreeStates_TwoQubits (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -699,7 +699,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T204_ThreeStates_TwoQubits_Phases_Test\n",
"%kata T204_ThreeStates_TwoQubits_Phases\n",
"\n",
"operation ThreeStates_TwoQubits_Phases (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -736,7 +736,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T205_Hardy_State_Test\n",
"%kata T205_Hardy_State\n",
"\n",
"operation Hardy_State (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -775,7 +775,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T206_WState_PowerOfTwo_Test\n",
"%kata T206_WState_PowerOfTwo\n",
"\n",
"operation WState_PowerOfTwo (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -814,7 +814,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T207_WState_Arbitrary_Test\n",
"%kata T207_WState_Arbitrary\n",
"\n",
"operation WState_Arbitrary (qs : Qubit[]) : Unit {\n",
" // ...\n",

Просмотреть файл

@ -39,7 +39,7 @@ namespace Quantum.Kata.Superposition {
operation PlusState (q : Qubit) : Unit {
// Hadamard gate H will convert |0⟩ state to |+⟩ state.
// Type the following: H(q);
// Then rebuild the project and rerun the tests - T01_PlusState_Test should now pass!
// Then rebuild the project and rerun the tests - T01_PlusState should now pass!
// ...
}

Просмотреть файл

@ -69,33 +69,33 @@ namespace Quantum.Kata.Superposition {
}
@Test("QuantumSimulator")
operation T101_PlusState_Test () : Unit {
operation T101_PlusState () : Unit {
AssertEqualOnZeroState(1, ArrayWrapperOperation(PlusState, _), ArrayWrapperOperationA(PlusState_Reference, _), true, "");
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T102_MinusState_Test () : Unit {
operation T102_MinusState () : Unit {
AssertEqualOnZeroState(1, ArrayWrapperOperation(MinusState, _), ArrayWrapperOperationA(MinusState_Reference, _), true, "");
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T103_AllBasisVectors_TwoQubits_Test () : Unit {
operation T103_AllBasisVectors_TwoQubits () : Unit {
// We only check for 2 qubits.
AssertEqualOnZeroState(2, AllBasisVectors_TwoQubits, AllBasisVectors_TwoQubits_Reference, true, "");
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T104_AllBasisVectorWithPhaseFlip_TwoQubits_Test() : Unit {
operation T104_AllBasisVectorWithPhaseFlip_TwoQubits() : Unit {
AssertEqualOnZeroState(2, AllBasisVectorWithPhaseFlip_TwoQubits, AllBasisVectorWithPhaseFlip_TwoQubits_Reference, true, "");
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T105_AllBasisVectorsWithPhases_TwoQubits_Test () : Unit {
operation T105_AllBasisVectorsWithPhases_TwoQubits () : Unit {
// We only check for 2 qubits.
AssertEqualOnZeroState(2, AllBasisVectorsWithPhases_TwoQubits, AllBasisVectorsWithPhases_TwoQubits_Reference, true, "");
}
@ -103,14 +103,14 @@ namespace Quantum.Kata.Superposition {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T106_BellState_Test () : Unit {
operation T106_BellState () : Unit {
AssertEqualOnZeroState(2, BellState, BellState_Reference, true, "");
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T107_AllBellStates_Test () : Unit {
operation T107_AllBellStates () : Unit {
for (i in 0 .. 3) {
AssertEqualOnZeroState(2, AllBellStates(_, i), AllBellStates_Reference(_, i), true, $"index = {i}");
}
@ -119,7 +119,7 @@ namespace Quantum.Kata.Superposition {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T108_GHZ_State_Test () : Unit {
operation T108_GHZ_State () : Unit {
// for N = 1 it's just |+⟩
AssertEqualOnZeroState(1, GHZ_State, ArrayWrapperOperationA(PlusState_Reference, _), true, "N = 1");
@ -135,7 +135,7 @@ namespace Quantum.Kata.Superposition {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T109_AllBasisVectorsSuperposition_Test () : Unit {
operation T109_AllBasisVectorsSuperposition () : Unit {
// for N = 1 it's just |+⟩
AssertEqualOnZeroState(1, AllBasisVectorsSuperposition, ArrayWrapperOperationA(PlusState_Reference, _), true, "N = 1");
@ -150,7 +150,7 @@ namespace Quantum.Kata.Superposition {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T110_EvenOddNumbersSuperposition_Test () : Unit {
operation T110_EvenOddNumbersSuperposition () : Unit {
for (n in 1 .. 2) {
for (isEven in [false, true]) {
AssertEqualOnZeroState(n, EvenOddNumbersSuperposition(_, isEven), EvenOddNumbersSuperposition_Reference(_, isEven), true, $"N = {n}, isEven = {isEven}");
@ -167,7 +167,7 @@ namespace Quantum.Kata.Superposition {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T111_ZeroAndBitstringSuperposition_Test () : Unit {
operation T111_ZeroAndBitstringSuperposition () : Unit {
// compare with results of previous operations
mutable b = [true];
AssertEqualOnZeroState(Length(b), ZeroAndBitstringSuperposition(_, b),
@ -197,7 +197,7 @@ namespace Quantum.Kata.Superposition {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T112_TwoBitstringSuperposition_Test () : Unit {
operation T112_TwoBitstringSuperposition () : Unit {
// open tests
// diff in the first position
mutable b1 = [true];
@ -247,7 +247,7 @@ namespace Quantum.Kata.Superposition {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T113_FourBitstringSuperposition_Test () : Unit {
operation T113_FourBitstringSuperposition () : Unit {
// cross-tests
mutable bits = [[false, false], [false, true], [true, false], [true, true]];
@ -286,7 +286,7 @@ namespace Quantum.Kata.Superposition {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T114_AllStatesWithParitySuperposition_Test () : Unit {
operation T114_AllStatesWithParitySuperposition () : Unit {
// remember to repeat the tests (for the small case of N = 2), lest the post-selection solution doesn't detect failure and retry
for (i in 1 .. 10) {
for (parity in 0 .. 1) {
@ -306,7 +306,7 @@ namespace Quantum.Kata.Superposition {
//////////////////////////////////////////////////////////////////
@Test("QuantumSimulator")
operation T201_UnequalSuperposition_Test () : Unit {
operation T201_UnequalSuperposition () : Unit {
// cross-test
AssertEqualOnZeroState(1, ArrayWrapperOperation(UnequalSuperposition(_, 0.5 * PI()), _), ApplyToEachA(X, _), true, "α = 0.5 π");
AssertEqualOnZeroState(1, ArrayWrapperOperation(UnequalSuperposition(_, 0.25 * PI()), _), ArrayWrapperOperationA(PlusState_Reference, _), true, "α = 0.25 π");
@ -323,31 +323,31 @@ namespace Quantum.Kata.Superposition {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T202_ControlledRotation_Test () : Unit {
operation T202_ControlledRotation () : Unit {
AssertEqualOnZeroState(2, ControlledRotation, ControlledRotation_Reference, true, "");
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T203_ThreeStates_TwoQubits_Test () : Unit {
operation T203_ThreeStates_TwoQubits () : Unit {
AssertEqualOnZeroState(2, ThreeStates_TwoQubits, ThreeStates_TwoQubits_Reference, true, "");
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T204_ThreeStates_TwoQubits_Phases_Test () : Unit {
operation T204_ThreeStates_TwoQubits_Phases () : Unit {
AssertEqualOnZeroState(2, ThreeStates_TwoQubits_Phases, ThreeStates_TwoQubits_Phases_Reference, true, "");
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T205_Hardy_State_Test () : Unit {
operation T205_Hardy_State () : Unit {
AssertEqualOnZeroState(2, Hardy_State, Hardy_State_Reference, true, "");
}
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T206_WState_PowerOfTwo_Test () : Unit {
operation T206_WState_PowerOfTwo () : Unit {
// separate check for N = 1 (return must be |1⟩)
AssertEqualOnZeroState(1, WState_PowerOfTwo, ApplyToEachA(X, _), true, "N = 1");
@ -362,7 +362,7 @@ namespace Quantum.Kata.Superposition {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T207_WState_Arbitrary_Test () : Unit {
operation T207_WState_Arbitrary () : Unit {
// separate check for N = 1 (return must be |1⟩)
AssertEqualOnZeroState(1, WState_Arbitrary, ApplyToEachA(X, _), true, "N = 1");

Просмотреть файл

@ -57,7 +57,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T101_PlusState_Test \n",
"%kata T101_PlusState \n",
"\n",
"operation PlusState (q : Qubit) : Unit {\n",
" H(q);\n",
@ -128,7 +128,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T102_MinusState_Test \n",
"%kata T102_MinusState \n",
"\n",
"operation MinusState (q : Qubit) : Unit {\n",
" X(q);\n",
@ -183,7 +183,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T103_AllBasisVectors_TwoQubits_Test\n",
"%kata T103_AllBasisVectors_TwoQubits\n",
"\n",
"operation AllBasisVectors_TwoQubits (qs : Qubit[]) : Unit {\n",
" H(qs[0]);\n",
@ -234,7 +234,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T104_AllBasisVectorWithPhaseFlip_TwoQubits_Test\n",
"%kata T104_AllBasisVectorWithPhaseFlip_TwoQubits\n",
"\n",
"operation AllBasisVectorWithPhaseFlip_TwoQubits (qs : Qubit[]) : Unit {\n",
" AllBasisVectors_TwoQubits(qs);\n",
@ -332,7 +332,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T105_AllBasisVectorsWithPhases_TwoQubits_Test\n",
"%kata T105_AllBasisVectorsWithPhases_TwoQubits\n",
"\n",
"operation AllBasisVectorsWithPhases_TwoQubits (qs : Qubit[]) : Unit {\n",
" H(qs[0]);\n",
@ -456,7 +456,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T106_BellState_Test\n",
"%kata T106_BellState\n",
"\n",
"operation BellState (qs : Qubit[]) : Unit {\n",
" H(qs[0]);\n",
@ -595,7 +595,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T107_AllBellStates_Test\n",
"%kata T107_AllBellStates\n",
"\n",
"operation AllBellStates (qs : Qubit[], index : Int) : Unit {\n",
" H(qs[0]);\n",
@ -649,7 +649,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T107_AllBellStates_Test\n",
"%kata T107_AllBellStates\n",
" \n",
"open Microsoft.Quantum.Convert;\n",
"\n",

Просмотреть файл

@ -66,7 +66,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T108_GHZ_State_Test\n",
"%kata T108_GHZ_State\n",
"\n",
"open Microsoft.Quantum.Arrays;\n",
"\n",
@ -130,7 +130,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T109_AllBasisVectorsSuperposition_Test\n",
"%kata T109_AllBasisVectorsSuperposition\n",
"\n",
"operation AllBasisVectorsSuperposition (qs : Qubit[]) : Unit {\n",
" for (q in qs) {\n",
@ -203,7 +203,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T110_EvenOddNumbersSuperposition_Test\n",
"%kata T110_EvenOddNumbersSuperposition\n",
"\n",
"operation EvenOddNumbersSuperposition (qs : Qubit[], isEven : Bool) : Unit is Adj {\n",
" let N = Length(qs);\n",
@ -273,7 +273,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T111_ZeroAndBitstringSuperposition_Test\n",
"%kata T111_ZeroAndBitstringSuperposition\n",
"\n",
"operation ZeroAndBitstringSuperposition (qs : Qubit[], bits : Bool[]) : Unit {\n",
" H(qs[0]);\n",
@ -340,7 +340,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T112_TwoBitstringSuperposition_Test\n",
"%kata T112_TwoBitstringSuperposition\n",
"\n",
"operation TwoBitstringSuperposition (qs : Qubit[], bits1 : Bool[], bits2 : Bool[]) : Unit {\n",
" using (q = Qubit()) {\n",
@ -394,7 +394,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T112_TwoBitstringSuperposition_Test\n",
"%kata T112_TwoBitstringSuperposition\n",
"\n",
"operation TwoBitstringSuperposition (qs : Qubit[], bits1 : Bool[], bits2 : Bool[]) : Unit {\n",
" // find the index of the first bit at which the bit strings are different\n",
@ -483,7 +483,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T113_FourBitstringSuperposition_Test\n",
"%kata T113_FourBitstringSuperposition\n",
"\n",
"operation FourBitstringSuperposition (qs : Qubit[], bits : Bool[][]) : Unit {\n",
" using (anc = Qubit[2]) {\n",
@ -550,7 +550,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T113_FourBitstringSuperposition_Test\n",
"%kata T113_FourBitstringSuperposition\n",
"\n",
"open Microsoft.Quantum.Convert;\n",
"open Microsoft.Quantum.Math;\n",
@ -652,7 +652,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T114_AllStatesWithParitySuperposition_Test\n",
"%kata T114_AllStatesWithParitySuperposition\n",
"\n",
"operation AllStatesWithParitySuperposition (qs : Qubit[], parity : Int) : Unit is Adj+Ctl {\n",
" // base of recursion: if N = 1, set the qubit to parity\n",
@ -696,7 +696,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T114_AllStatesWithParitySuperposition_Test\n",
"%kata T114_AllStatesWithParitySuperposition\n",
"\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
@ -811,7 +811,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T201_UnequalSuperposition_Test \n",
"%kata T201_UnequalSuperposition \n",
"\n",
"operation UnequalSuperposition (q : Qubit, alpha : Double) : Unit {\n",
" Ry(2.0 * alpha, q);\n",
@ -868,7 +868,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T202_ControlledRotation_Test \n",
"%kata T202_ControlledRotation \n",
"\n",
"operation ControlledRotation (qs : Qubit[]) : Unit {\n",
" H(qs[0]);\n",
@ -937,7 +937,7 @@
},
"outputs": [],
"source": [
"%kata T203_ThreeStates_TwoQubits_Test\n",
"%kata T203_ThreeStates_TwoQubits\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",
"operation ThreeStates_TwoQubits (qs : Qubit[]) : Unit {\n",
@ -1000,7 +1000,7 @@
},
"outputs": [],
"source": [
"%kata T203_ThreeStates_TwoQubits_Test\n",
"%kata T203_ThreeStates_TwoQubits\n",
"open Microsoft.Quantum.Math;\n",
"\n",
"operation ThreeStates_TwoQubits (qs : Qubit[]) : Unit {\n",
@ -1060,7 +1060,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T204_ThreeStates_TwoQubits_Phases_Test\n",
"%kata T204_ThreeStates_TwoQubits_Phases\n",
"open Microsoft.Quantum.Math;\n",
"\n",
"operation ThreeStates_TwoQubits_Phases (qs : Qubit[]) : Unit {\n",
@ -1268,7 +1268,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T205_Hardy_State_Test\n",
"%kata T205_Hardy_State\n",
"\n",
"open Microsoft.Quantum.Math;\n",
"\n",
@ -1360,7 +1360,7 @@
},
"outputs": [],
"source": [
"%kata T206_WState_PowerOfTwo_Test\n",
"%kata T206_WState_PowerOfTwo\n",
"\n",
"operation WState_PowerOfTwo (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" let N = Length(qs);\n",
@ -1404,7 +1404,7 @@
},
"outputs": [],
"source": [
"%kata T206_WState_PowerOfTwo_Test\n",
"%kata T206_WState_PowerOfTwo\n",
"\n",
"operation WState_PowerOfTwo (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" let N = Length(qs);\n",
@ -1487,7 +1487,7 @@
},
"outputs": [],
"source": [
"%kata T207_WState_Arbitrary_Test\n",
"%kata T207_WState_Arbitrary\n",
"\n",
"open Microsoft.Quantum.Convert;\n",
"open Microsoft.Quantum.Math;\n",
@ -1526,7 +1526,7 @@
},
"outputs": [],
"source": [
"%kata T207_WState_Arbitrary_Test\n",
"%kata T207_WState_Arbitrary\n",
"\n",
"open Microsoft.Quantum.Convert;\n",
"open Microsoft.Quantum.Math;\n",
@ -1583,7 +1583,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T207_WState_Arbitrary_Test\n",
"%kata T207_WState_Arbitrary\n",
"\n",
"open Microsoft.Quantum.Measurement;\n",
"\n",

Просмотреть файл

@ -45,7 +45,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_Entangle_Test \n",
"%kata T11_Entangle \n",
"\n",
"operation Entangle (qAlice : Qubit, qBob : Qubit) : Unit {\n",
" // ...\n",
@ -75,7 +75,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_SendMessage_Test \n",
"%kata T12_SendMessage \n",
"\n",
"operation SendMessage (qAlice : Qubit, qMessage : Qubit) : (Bool, Bool) {\n",
" // ...\n",
@ -104,7 +104,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T13_ReconstructMessage_Test \n",
"%kata T13_ReconstructMessage \n",
"\n",
"operation ReconstructMessage (qBob : Qubit, (b1 : Bool, b2 : Bool)) : Unit {\n",
" // ...\n",
@ -133,7 +133,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_StandardTeleport_Test\n",
"%kata T14_StandardTeleport\n",
"\n",
"operation StandardTeleport (qAlice : Qubit, qBob : Qubit, qMessage : Qubit) : Unit {\n",
" // ...\n",
@ -165,7 +165,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T15_PrepareAndSendMessage_Test\n",
"%kata T15_PrepareAndSendMessage\n",
"\n",
"operation PrepareAndSendMessage (qAlice : Qubit, basis : Pauli, state : Bool) : (Bool, Bool) {\n",
" // ...\n",
@ -198,7 +198,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T16_ReconstructAndMeasureMessage_Test\n",
"%kata T16_ReconstructAndMeasureMessage\n",
"\n",
"operation ReconstructAndMeasureMessage (qBob : Qubit, (b1 : Bool, b2 : Bool), basis : Pauli) : Bool {\n",
" \n",
@ -277,7 +277,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T21_ReconstructMessage_PhiMinus_Test\n",
"%kata T21_ReconstructMessage_PhiMinus\n",
"\n",
"operation ReconstructMessage_PhiMinus (qBob : Qubit, (b1 : Bool, b2 : Bool)) : Unit {\n",
" // ...\n",
@ -297,7 +297,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T22_ReconstructMessage_PsiPlus_Test\n",
"%kata T22_ReconstructMessage_PsiPlus\n",
"\n",
"operation ReconstructMessage_PsiPlus (qBob : Qubit, (b1 : Bool, b2 : Bool)) : Unit {\n",
" // ...\n",
@ -317,7 +317,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T23_ReconstructMessage_PsiMinus_Test\n",
"%kata T23_ReconstructMessage_PsiMinus\n",
"\n",
"operation ReconstructMessage_PsiMinus (qBob : Qubit, (b1 : Bool, b2 : Bool)) : Unit {\n",
" // ...\n",
@ -355,7 +355,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T31_MeasurementFreeTeleport_Test\n",
"%kata T31_MeasurementFreeTeleport\n",
"\n",
"operation MeasurementFreeTeleport (qAlice : Qubit, qBob : Qubit, qMessage : Qubit) : Unit {\n",
" // ...\n",
@ -391,7 +391,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T41_EntangleThreeQubits_Test\n",
"%kata T41_EntangleThreeQubits\n",
"\n",
"operation EntangleThreeQubits (qAlice : Qubit, qBob : Qubit, qCharlie : Qubit) : Unit {\n",
" // ...\n",
@ -420,7 +420,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T42_ReconstructMessageWhenThreeEntangledQubits_Test\n",
"%kata T42_ReconstructMessageWhenThreeEntangledQubits\n",
"\n",
"operation ReconstructMessageWhenThreeEntangledQubits (qCharlie : Qubit, (b1 : Bool, b2 : Bool), b3 : Bool) : Unit {\n",
" // ...\n",

Просмотреть файл

@ -16,7 +16,7 @@ namespace Quantum.Kata.Teleportation {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T11_Entangle_Test () : Unit {
operation T11_Entangle () : Unit {
using ((q0, q1) = (Qubit(), Qubit())) {
// Apply operation that needs to be tested
Entangle(q0, q1);
@ -125,7 +125,7 @@ namespace Quantum.Kata.Teleportation {
// Test the 'SendMessage' operation by using it as one part of full teleportation,
// taking reference implementation for the other parts.
@Test("QuantumSimulator")
operation T12_SendMessage_Test () : Unit {
operation T12_SendMessage () : Unit {
let teleport = ComposeTeleportation(StatePrep_BellState(_, _, 0), SendMessage, ReconstructMessage_Reference, _, _, _);
TeleportTestLoop(teleport);
}
@ -134,7 +134,7 @@ namespace Quantum.Kata.Teleportation {
// Test the 'ReconstructMessage' operation by using it as one part of full teleportation,
// taking reference implementation for the other parts.
@Test("QuantumSimulator")
operation T13_ReconstructMessage_Test () : Unit {
operation T13_ReconstructMessage () : Unit {
let teleport = ComposeTeleportation(StatePrep_BellState(_, _, 0), SendMessage_Reference, ReconstructMessage, _, _, _);
TeleportTestLoop(teleport);
}
@ -142,7 +142,7 @@ namespace Quantum.Kata.Teleportation {
// Test the full Teleport operation
@Test("QuantumSimulator")
operation T14_StandardTeleport_Test () : Unit {
operation T14_StandardTeleport () : Unit {
TeleportTestLoop(StandardTeleport);
}
@ -180,7 +180,7 @@ namespace Quantum.Kata.Teleportation {
// Test the 'PrepareAndSendMessage' operation by using it as one part of full teleportation,
// taking reference implementation for the other parts.
@Test("QuantumSimulator")
operation T15_PrepareAndSendMessage_Test () : Unit {
operation T15_PrepareAndSendMessage () : Unit {
TeleportPreparedStateTestLoop(PrepareAndSendMessage, ReconstructAndMeasureMessage_Reference);
}
@ -188,7 +188,7 @@ namespace Quantum.Kata.Teleportation {
// Test the 'ReconstructAndMeasureMessage' operation by using it as one part of full teleportation,
// taking reference implementation for the other parts.
@Test("QuantumSimulator")
operation T16_ReconstructAndMeasureMessage_Test () : Unit {
operation T16_ReconstructAndMeasureMessage () : Unit {
TeleportPreparedStateTestLoop(PrepareAndSendMessage_Reference, ReconstructAndMeasureMessage);
}
@ -196,19 +196,19 @@ namespace Quantum.Kata.Teleportation {
// ------------------------------------------------------
// Test variations of the teleport protocol using different state prep procedures
@Test("QuantumSimulator")
operation T21_ReconstructMessage_PhiMinus_Test () : Unit {
operation T21_ReconstructMessage_PhiMinus () : Unit {
let teleport = ComposeTeleportation(StatePrep_BellState(_, _, 1), SendMessage_Reference, ReconstructMessage_PhiMinus, _, _, _);
TeleportTestLoop(teleport);
}
@Test("QuantumSimulator")
operation T22_ReconstructMessage_PsiPlus_Test () : Unit {
operation T22_ReconstructMessage_PsiPlus () : Unit {
let teleport = ComposeTeleportation(StatePrep_BellState(_, _, 2), SendMessage_Reference, ReconstructMessage_PsiPlus, _, _, _);
TeleportTestLoop(teleport);
}
@Test("QuantumSimulator")
operation T23_ReconstructMessage_PsiMinus_Test () : Unit {
operation T23_ReconstructMessage_PsiMinus () : Unit {
let teleport = ComposeTeleportation(StatePrep_BellState(_, _, 3), SendMessage_Reference, ReconstructMessage_PsiMinus, _, _, _);
TeleportTestLoop(teleport);
}
@ -216,7 +216,7 @@ namespace Quantum.Kata.Teleportation {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T31_MeasurementFreeTeleport_Test () : Unit {
operation T31_MeasurementFreeTeleport () : Unit {
let setupPsiOps = [I, X, H, Ry(42.0, _)];
let numRepetitions = 100;
@ -237,7 +237,7 @@ namespace Quantum.Kata.Teleportation {
// ------------------------------------------------------
@Test("QuantumSimulator")
operation T41_EntangleThreeQubits_Test () : Unit {
operation T41_EntangleThreeQubits () : Unit {
using ((qAlice, qBob, qCharlie) = (Qubit(), Qubit(), Qubit())) {
// Apply operation that needs to be tested
@ -252,7 +252,7 @@ namespace Quantum.Kata.Teleportation {
}
@Test("QuantumSimulator")
operation T42_ReconstructMessageWhenThreeEntangledQubits_Test () : Unit {
operation T42_ReconstructMessageWhenThreeEntangledQubits () : Unit {
let setupPsiOps = [I, X, H, Ry(42.0, _)];
let numRepetitions = 100;

Просмотреть файл

@ -21,7 +21,7 @@ namespace Quantum.Kata.TruthTables {
}
@Test("QuantumSimulator")
operation T1_ProjectiveTruthTables_Test () : Unit {
operation T1_ProjectiveTruthTables () : Unit {
let (x1, x2, x3) = ProjectiveTruthTables();
EqualityFactTT(x1, TruthTable(0b10101010, 3), "x₁");
EqualityFactTT(x2, TruthTable(0b11001100, 3), "x₂");
@ -29,7 +29,7 @@ namespace Quantum.Kata.TruthTables {
}
@Test("QuantumSimulator")
operation T2_TTAnd_Test () : Unit {
operation T2_TTAnd () : Unit {
let (x1, x2, x3) = ProjectiveTruthTables_Reference();
EqualityFactTT(TTAnd(x1, x2), TruthTable(0b10001000, 3), "x₁ ∧ x₂");
EqualityFactTT(TTAnd(x1, x3), TruthTable(0b10100000, 3), "x₁ ∧ x₃");
@ -37,7 +37,7 @@ namespace Quantum.Kata.TruthTables {
}
@Test("QuantumSimulator")
operation T3_TTOr_Test () : Unit {
operation T3_TTOr () : Unit {
let (x1, x2, x3) = ProjectiveTruthTables_Reference();
EqualityFactTT(TTOr(x1, x2), TruthTable(0b11101110, 3), "x₁ x₂");
EqualityFactTT(TTOr(x1, x3), TruthTable(0b11111010, 3), "x₁ x₃");
@ -45,7 +45,7 @@ namespace Quantum.Kata.TruthTables {
}
@Test("QuantumSimulator")
operation T4_TTXor_Test () : Unit {
operation T4_TTXor () : Unit {
let (x1, x2, x3) = ProjectiveTruthTables_Reference();
EqualityFactTT(TTXor(x1, x2), TruthTable(0b01100110, 3), "x₁ ⊕ x₂");
EqualityFactTT(TTXor(x1, x3), TruthTable(0b01011010, 3), "x₁ ⊕ x₃");
@ -53,7 +53,7 @@ namespace Quantum.Kata.TruthTables {
}
@Test("QuantumSimulator")
operation T5_TTNot_Test () : Unit {
operation T5_TTNot () : Unit {
let (x1, x2, x3) = ProjectiveTruthTables_Reference();
EqualityFactTT(TTNot(x1), TruthTable(0b01010101, 3), "¬x₁");
EqualityFactTT(TTNot(x2), TruthTable(0b00110011, 3), "¬x₂");
@ -61,13 +61,13 @@ namespace Quantum.Kata.TruthTables {
}
@Test("QuantumSimulator")
operation T6_IfThenElseTruthTable_Test () : Unit {
operation T6_IfThenElseTruthTable () : Unit {
let (x1, x2, x3) = ProjectiveTruthTables_Reference();
EqualityFactTT(TTIfThenElse(x1, x2, x3), TruthTable(0b11011000, 3), "if x₁ then x₂ else x₃");
}
@Test("QuantumSimulator")
operation T7_AllMinterms_Test () : Unit {
operation T7_AllMinterms () : Unit {
let (x1, x2, x3) = ProjectiveTruthTables_Reference();
let testTT = TTIfThenElse_Reference(x1, x2, x3);
Message($"Testing on truth table {testTT}");
@ -83,7 +83,7 @@ namespace Quantum.Kata.TruthTables {
}
@Test("QuantumSimulator")
operation T8_ApplyFunction_Test () : Unit {
operation T8_ApplyFunction () : Unit {
let (x1, x2, x3) = ProjectiveTruthTables_Reference();
let tt = TTIfThenElse_Reference(x1, x2, x3);
let opUser = _ApplyFunctionWrap(ApplyXControlledOnFunction(tt, _, _), _);

Просмотреть файл

@ -107,7 +107,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T1_ProjectiveTruthTables_Test \n",
"%kata T1_ProjectiveTruthTables \n",
"\n",
"open Quantum.Kata.TruthTables;\n",
"\n",
@ -145,7 +145,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T2_TTAnd_Test \n",
"%kata T2_TTAnd \n",
"\n",
"open Quantum.Kata.TruthTables;\n",
"\n",
@ -170,7 +170,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T3_TTOr_Test \n",
"%kata T3_TTOr \n",
"\n",
"open Quantum.Kata.TruthTables;\n",
"\n",
@ -195,7 +195,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T4_TTXor_Test \n",
"%kata T4_TTXor \n",
"\n",
"open Quantum.Kata.TruthTables;\n",
"\n",
@ -227,7 +227,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T5_TTNot_Test \n",
"%kata T5_TTNot \n",
"\n",
"open Quantum.Kata.TruthTables;\n",
"\n",
@ -253,7 +253,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T6_IfThenElseTruthTable_Test \n",
"%kata T6_IfThenElseTruthTable \n",
"\n",
"open Quantum.Kata.TruthTables;\n",
"\n",
@ -287,7 +287,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T7_AllMinterms_Test \n",
"%kata T7_AllMinterms \n",
"\n",
"open Quantum.Kata.TruthTables;\n",
"\n",
@ -312,7 +312,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T8_ApplyFunction_Test \n",
"%kata T8_ApplyFunction \n",
"\n",
"open Quantum.Kata.TruthTables;\n",
"\n",

Просмотреть файл

@ -52,7 +52,7 @@ namespace Quantum.Kata.UnitaryPatterns {
operation MainDiagonal (qs : Qubit[]) : Unit {
// The simplest example of such a unitary transformation is represented by an identity matrix.
// This means that the operation doesn't need to do anything with the input qubits.
// Build the project and run the tests to see that T01_MainDiagonal_Test test passes.
// Build the project and run the tests to see that T01_MainDiagonal test passes.
// You are welcome to try and come up with other diagonal unitaries.
// ...

Просмотреть файл

@ -69,7 +69,7 @@ namespace Quantum.Kata.UnitaryPatterns {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T01_MainDiagonal_Test () : Unit {
operation T01_MainDiagonal () : Unit {
for (n in 2 .. 5) {
AssertOperationMatrixMatchesPattern(n, MainDiagonal, MainDiagonal_Pattern);
}
@ -82,7 +82,7 @@ namespace Quantum.Kata.UnitaryPatterns {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T02_AllNonZero_Test () : Unit {
operation T02_AllNonZero () : Unit {
for (n in 2 .. 5) {
AssertOperationMatrixMatchesPattern(n, AllNonZero, AllNonZero_Pattern);
}
@ -95,7 +95,7 @@ namespace Quantum.Kata.UnitaryPatterns {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T03_BlockDiagonal_Test () : Unit {
operation T03_BlockDiagonal () : Unit {
for (n in 2 .. 5) {
AssertOperationMatrixMatchesPattern(n, BlockDiagonal, BlockDiagonal_Pattern);
}
@ -111,7 +111,7 @@ namespace Quantum.Kata.UnitaryPatterns {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T04_Quarters_Test () : Unit {
operation T04_Quarters () : Unit {
for (n in 2 .. 5) {
AssertOperationMatrixMatchesPattern(n, Quarters, Quarters_Pattern);
}
@ -127,7 +127,7 @@ namespace Quantum.Kata.UnitaryPatterns {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T05_EvenChessPattern_Test () : Unit {
operation T05_EvenChessPattern () : Unit {
for (n in 2 .. 5) {
AssertOperationMatrixMatchesPattern(n, EvenChessPattern, EvenChessPattern_Pattern);
}
@ -143,7 +143,7 @@ namespace Quantum.Kata.UnitaryPatterns {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T06_OddChessPattern_Test () : Unit {
operation T06_OddChessPattern () : Unit {
for (n in 2 .. 5) {
AssertOperationMatrixMatchesPattern(n, OddChessPattern, OddChessPattern_Pattern);
}
@ -156,7 +156,7 @@ namespace Quantum.Kata.UnitaryPatterns {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T07_Antidiagonal_Test () : Unit {
operation T07_Antidiagonal () : Unit {
for (n in 2 .. 5) {
AssertOperationMatrixMatchesPattern(n, Antidiagonal, Antidiagonal_Pattern);
}
@ -169,7 +169,7 @@ namespace Quantum.Kata.UnitaryPatterns {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T08_ChessPattern2x2_Test () : Unit {
operation T08_ChessPattern2x2 () : Unit {
for (n in 2 .. 5) {
AssertOperationMatrixMatchesPattern(n, ChessPattern2x2, ChessPattern2x2_Pattern);
}
@ -192,7 +192,7 @@ namespace Quantum.Kata.UnitaryPatterns {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T09_TwoPatterns_Test () : Unit {
operation T09_TwoPatterns () : Unit {
for (n in 2 .. 5) {
AssertOperationMatrixMatchesPattern(n, TwoPatterns, TwoPatterns_Pattern);
}
@ -218,7 +218,7 @@ namespace Quantum.Kata.UnitaryPatterns {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T10_IncreasingBlocks_Test () : Unit {
operation T10_IncreasingBlocks () : Unit {
for (n in 2 .. 5) {
AssertOperationMatrixMatchesPattern(n, IncreasingBlocks, IncreasingBlocks_Pattern);
}
@ -231,7 +231,7 @@ namespace Quantum.Kata.UnitaryPatterns {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T11_XWing_Fighter_Test () : Unit {
operation T11_XWing_Fighter () : Unit {
for (n in 2 .. 5) {
AssertOperationMatrixMatchesPattern(n, XWing_Fighter, XWing_Fighter_Pattern);
}
@ -246,7 +246,7 @@ namespace Quantum.Kata.UnitaryPatterns {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T12_Rhombus_Test () : Unit {
operation T12_Rhombus () : Unit {
for (n in 2 .. 5) {
AssertOperationMatrixMatchesPattern(n, Rhombus, Rhombus_Pattern);
}
@ -264,7 +264,7 @@ namespace Quantum.Kata.UnitaryPatterns {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T13_TIE_Fighter_Test () : Unit {
operation T13_TIE_Fighter () : Unit {
for (n in 2 .. 5) {
AssertOperationMatrixMatchesPattern(n, TIE_Fighter, TIE_Fighter_Pattern);
}
@ -285,7 +285,7 @@ namespace Quantum.Kata.UnitaryPatterns {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T14_Creeper_Test () : Unit {
operation T14_Creeper () : Unit {
AssertOperationMatrixMatchesPattern(3, Creeper, Creeper_Pattern);
}
@ -295,7 +295,7 @@ namespace Quantum.Kata.UnitaryPatterns {
}
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T15_Hessenberg_Matrix_Test () : Unit {
operation T15_Hessenberg_Matrix () : Unit {
for (n in 2 .. 4) {
AssertOperationMatrixMatchesPattern(n, Hessenberg_Matrix, Hessenberg_Matrix_Pattern);
}

Просмотреть файл

@ -60,7 +60,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T01_MainDiagonal_Test \n",
"%kata T01_MainDiagonal \n",
"\n",
"operation MainDiagonal (qs : Qubit[]) : Unit {\n",
" // The simplest example of such a unitary transformation is represented by an identity matrix.\n",
@ -106,7 +106,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T02_AllNonZero_Test \n",
"%kata T02_AllNonZero \n",
"\n",
"operation AllNonZero (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -152,7 +152,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T03_BlockDiagonal_Test \n",
"%kata T03_BlockDiagonal \n",
"\n",
"operation BlockDiagonal (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -205,7 +205,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T04_Quarters_Test \n",
"%kata T04_Quarters \n",
"\n",
"operation Quarters (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -248,7 +248,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T05_EvenChessPattern_Test \n",
"%kata T05_EvenChessPattern \n",
"\n",
"operation EvenChessPattern (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -291,7 +291,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T06_OddChessPattern_Test \n",
"%kata T06_OddChessPattern \n",
"\n",
"operation OddChessPattern (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -333,7 +333,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T07_Antidiagonal_Test \n",
"%kata T07_Antidiagonal \n",
"\n",
"operation Antidiagonal (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -380,7 +380,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T08_ChessPattern2x2_Test \n",
"%kata T08_ChessPattern2x2 \n",
"\n",
"operation ChessPattern2x2 (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -424,7 +424,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T09_TwoPatterns_Test \n",
"%kata T09_TwoPatterns \n",
"\n",
"operation TwoPatterns (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -475,7 +475,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T10_IncreasingBlocks_Test \n",
"%kata T10_IncreasingBlocks \n",
"\n",
"operation IncreasingBlocks (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -522,7 +522,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_XWing_Fighter_Test \n",
"%kata T11_XWing_Fighter \n",
"\n",
"operation XWing_Fighter (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -575,7 +575,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_Rhombus_Test \n",
"%kata T12_Rhombus \n",
"\n",
"operation Rhombus (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -630,7 +630,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T13_TIE_Fighter_Test \n",
"%kata T13_TIE_Fighter \n",
"\n",
"operation TIE_Fighter (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -673,7 +673,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_Creeper_Test \n",
"%kata T14_Creeper \n",
"\n",
"operation Creeper (qs : Qubit[]) : Unit {\n",
" // ...\n",
@ -727,7 +727,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T15_Hessenberg_Matrix_Test \n",
"%kata T15_Hessenberg_Matrix \n",
"\n",
"operation Hessenberg_Matrix (qs : Qubit[]) : Unit {\n",
" // ...\n",

Просмотреть файл

@ -68,7 +68,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T01_MainDiagonal_Test \n",
"%kata T01_MainDiagonal \n",
"\n",
"operation MainDiagonal (qs : Qubit[]) : Unit {\n",
" // We don't need to write out applying identity unitary, since it is a no-op\n",
@ -123,7 +123,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T02_AllNonZero_Test \n",
"%kata T02_AllNonZero \n",
"\n",
"operation AllNonZero (qs : Qubit[]) : Unit {\n",
" ApplyToEach(H, qs); \n",
@ -196,7 +196,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T03_BlockDiagonal_Test \n",
"%kata T03_BlockDiagonal \n",
"\n",
"operation BlockDiagonal (qs : Qubit[]) : Unit {\n",
" H(qs[0]);\n",
@ -265,7 +265,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T04_Quarters_Test \n",
"%kata T04_Quarters \n",
"\n",
"operation Quarters (qs : Qubit[]) : Unit {\n",
" // Same as in previous task, the little endian encoding of indices means that \n",
@ -330,7 +330,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T05_EvenChessPattern_Test \n",
"%kata T05_EvenChessPattern \n",
"\n",
"operation EvenChessPattern (qs : Qubit[]) : Unit {\n",
" // Same as in previous task, the little endian encoding of indices means that \n",
@ -392,7 +392,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T06_OddChessPattern_Test \n",
"%kata T06_OddChessPattern \n",
"\n",
"operation OddChessPattern (qs : Qubit[]) : Unit {\n",
" X(qs[0]);\n",
@ -447,7 +447,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T07_Antidiagonal_Test \n",
"%kata T07_Antidiagonal \n",
"\n",
"operation Antidiagonal (qs : Qubit[]) : Unit {\n",
" ApplyToEach(X, qs); \n",
@ -519,7 +519,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T08_ChessPattern2x2_Test \n",
"%kata T08_ChessPattern2x2 \n",
"\n",
"operation ChessPattern2x2 (qs : Qubit[]) : Unit {\n",
" H(qs[0]);\n",
@ -618,7 +618,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T09_TwoPatterns_Test \n",
"%kata T09_TwoPatterns \n",
"\n",
"open Microsoft.Quantum.Arrays;\n",
"\n",
@ -698,7 +698,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T10_IncreasingBlocks_Test \n",
"%kata T10_IncreasingBlocks \n",
"\n",
"open Microsoft.Quantum.Arrays;\n",
"\n",
@ -876,7 +876,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T11_XWing_Fighter_Test \n",
"%kata T11_XWing_Fighter \n",
"\n",
"open Microsoft.Quantum.Arrays;\n",
"\n",
@ -967,7 +967,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T12_Rhombus_Test \n",
"%kata T12_Rhombus \n",
"\n",
"operation Rhombus (qs : Qubit[]) : Unit {\n",
" XWing_Fighter(qs);\n",
@ -1075,7 +1075,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T13_TIE_Fighter_Test \n",
"%kata T13_TIE_Fighter \n",
"\n",
"operation TIE_Fighter (qs : Qubit[]) : Unit {\n",
" let n = Length(qs);\n",
@ -1277,7 +1277,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T14_Creeper_Test \n",
"%kata T14_Creeper \n",
"\n",
"operation Creeper(qs : Qubit[]) : Unit {\n",
" X(qs[2]);\n",
@ -1450,7 +1450,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T15_Hessenberg_Matrix_Test\n",
"%kata T15_Hessenberg_Matrix\n",
"\n",
"open Microsoft.Quantum.Arrays;\n",
"\n",

Просмотреть файл

@ -57,7 +57,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
operation PhaseOracle_Zero_Reference (x : Qubit[]) : Unit is Adj {
// Since f(x) = 0 for all values of x, Uf|y⟩ = |y⟩.
// This means that the operation doesn't need to do any transformation to the inputs.
// Build the project and run the tests to see that T01_Oracle_Zero_Test test passes.
// Build the project and run the tests to see that T01_Oracle_Zero test passes.
}

Просмотреть файл

@ -107,7 +107,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T1_ClassicalFunction_Test \n",
"%kata T1_ClassicalFunction \n",
"\n",
"function Function_MostSignificantBit (x : Int, N : Int) : Int {\n",
" // ...\n",
@ -146,7 +146,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T2_ClassicalAlgorithm_Test \n",
"%kata T2_ClassicalAlgorithm \n",
"\n",
"operation IsFunctionConstant_Classical (N : Int, f : (Int -> Int)) : Bool {\n",
" // ...\n",
@ -351,7 +351,7 @@
},
"outputs": [],
"source": [
"%kata T3_QuantumOracle_Test\n",
"%kata T3_QuantumOracle\n",
"\n",
"operation PhaseOracle_MostSignificantBit (x : Qubit[]) : Unit {\n",
" // ...\n",
@ -491,7 +491,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T4_QuantumAlgorithm_Test\n",
"%kata T4_QuantumAlgorithm\n",
"\n",
"operation DeutschJozsaAlgorithm (N : Int, oracle : (Qubit[] => Unit)) : Bool {\n",
" // Create a boolean variable for storing the return value.\n",

Просмотреть файл

@ -25,7 +25,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
// Exercise 1.
@Test("QuantumSimulator")
operation T1_ClassicalFunction_Test () : Unit {
operation T1_ClassicalFunction () : Unit {
for (N in 1..5) {
for (x in 0..(1 <<< (N - 1)) - 1) {
let ret = Function_MostSignificantBit(x, N);
@ -56,7 +56,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
}
@Test("QuantumSimulator")
operation T2_ClassicalAlgorithm_Test () : Unit {
operation T2_ClassicalAlgorithm () : Unit {
CheckClassicalAlgorithm(4, Function_Zero_Reference, true, "f(x) = 0");
CheckClassicalAlgorithm(4, Function_One_Reference, true, "f(x) = 1");
CheckClassicalAlgorithm(4, Function_Xmod2_Reference, false, "f(x) = x mod 2");
@ -70,7 +70,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
// Exercise 3.
@Test("QuantumSimulator")
operation T3_QuantumOracle_Test () : Unit {
operation T3_QuantumOracle () : Unit {
for (N in 1..5) {
AssertOperationsEqualReferenced(N, PhaseOracle_MostSignificantBit, PhaseOracle_MostSignificantBit_Reference);
}
@ -104,7 +104,7 @@ namespace Quantum.Kata.DeutschJozsaAlgorithm {
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T4_QuantumAlgorithm_Test () : Unit {
operation T4_QuantumAlgorithm () : Unit {
ResetOracleCallsCount();
CheckQuantumAlgorithm(4, PhaseOracle_Zero_Reference, true, "f(x) = 0");

Просмотреть файл

@ -108,7 +108,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T1_CompoundGate_Test\n",
"%kata T1_CompoundGate\n",
"\n",
"operation CompoundGate (qs : Qubit[]) : Unit is Adj {\n",
" // ...\n",
@ -193,7 +193,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T2_BellState_Test\n",
"%kata T2_BellState\n",
"\n",
"operation BellState (qs : Qubit[]) : Unit is Adj {\n",
" // ...\n",
@ -362,7 +362,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T3_QubitSwap_Test\n",
"%kata T3_QubitSwap\n",
"\n",
"operation QubitSwap (qs : Qubit[], index1 : Int, index2 : Int) : Unit is Adj {\n",
" // ...\n",
@ -670,7 +670,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T4_ControlledRotation_Test\n",
"%kata T4_ControlledRotation\n",
"\n",
"operation ControlledRotation (qs : Qubit[], theta : Double) : Unit is Adj {\n",
" // ...\n",
@ -806,7 +806,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T5_MultiControls_Test\n",
"%kata T5_MultiControls\n",
"\n",
"operation MultiControls (controls : Qubit[], target : Qubit, controlBits : Bool[]) : Unit is Adj {\n",
" // ...\n",

Просмотреть файл

@ -14,7 +14,7 @@ namespace Quantum.Kata.MultiQubitGates {
open Microsoft.Quantum.Arrays;
@Test("QuantumSimulator")
operation T1_CompoundGate_Test () : Unit {
operation T1_CompoundGate () : Unit {
AssertOperationsEqualReferenced(3, CompoundGate, CompoundGate_Reference);
}
@ -33,12 +33,12 @@ namespace Quantum.Kata.MultiQubitGates {
}
@Test("QuantumSimulator")
operation T2_BellState_Test () : Unit {
operation T2_BellState () : Unit {
AssertEqualOnZeroState(BellState, BellState_Reference);
}
@Test("QuantumSimulator")
operation T3_QubitSwap_Test () : Unit {
operation T3_QubitSwap () : Unit {
for (N in 2 .. 5) {
for (j in 0 .. N-2) {
for (k in j+1 .. N-1) {
@ -49,7 +49,7 @@ namespace Quantum.Kata.MultiQubitGates {
}
@Test("QuantumSimulator")
operation T4_ControlledRotation_Test () : Unit {
operation T4_ControlledRotation () : Unit {
for (i in 0 .. 20) {
let angle = IntAsDouble(i) / 10.0;
AssertOperationsEqualReferenced(2, ControlledRotation(_, angle), ControlledRotation_Reference(_,angle));
@ -62,7 +62,7 @@ namespace Quantum.Kata.MultiQubitGates {
}
@Test("QuantumSimulator")
operation T5_MultiControls_Test () : Unit {
operation T5_MultiControls () : Unit {
for (i in 0 .. (2 ^ 4) - 1) {
let bits = IntAsBoolArray(i, 4);
AssertOperationsEqualReferenced(5, ArrayControlledOperationWrapper(MultiControls(_, _, bits), _), ArrayControlledOperationWrapper(MultiControls_Reference(_, _, bits), _));

Просмотреть файл

@ -90,7 +90,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T1_CompoundGate_Test\n",
"%kata T1_CompoundGate\n",
"\n",
"operation CompoundGate (qs : Qubit[]) : Unit is Adj {\n",
" S(qs[0]);\n",
@ -146,7 +146,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T2_BellState_Test\n",
"%kata T2_BellState\n",
"\n",
"operation BellState (qs : Qubit[]) : Unit is Adj {\n",
" H(qs[0]);\n",
@ -190,7 +190,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T3_QubitSwap_Test\n",
"%kata T3_QubitSwap\n",
"\n",
"operation QubitSwap (qs : Qubit[], index1 : Int, index2 : Int) : Unit is Adj {\n",
" SWAP(qs[index1], qs[index2]);\n",
@ -246,7 +246,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T4_ControlledRotation_Test\n",
"%kata T4_ControlledRotation\n",
"\n",
"operation ControlledRotation (qs : Qubit[], theta : Double) : Unit is Adj {\n",
" let controll = qs[0];\n",
@ -301,7 +301,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T5_MultiControls_Test\n",
"%kata T5_MultiControls\n",
"\n",
"operation MultiControls (controls : Qubit[], target : Qubit, controlBits : Bool[]) : Unit is Adj {\n",
" for (index in 0 .. Length(controls) - 1) {\n",
@ -333,7 +333,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T5_MultiControls_Test\n",
"%kata T5_MultiControls\n",
"\n",
"operation MultiControls (controls : Qubit[], target : Qubit, controlBits : Bool[]) : Unit is Adj {\n",
" within {\n",
@ -361,7 +361,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T5_MultiControls_Test\n",
"%kata T5_MultiControls\n",
"\n",
"operation MultiControls (controls : Qubit[], target : Qubit, controlBits : Bool[]) : Unit is Adj {\n",
" (ControlledOnBitString(controlBits, X))(controls, target);\n",

Просмотреть файл

@ -391,7 +391,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T1_PrepareState1_Test\n",
"%kata T1_PrepareState1\n",
"\n",
"operation PrepareState1 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -427,7 +427,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T2_PrepareState2_Test\n",
"%kata T2_PrepareState2\n",
"\n",
"operation PrepareState2 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -463,7 +463,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T3_PrepareState3_Test\n",
"%kata T3_PrepareState3\n",
"\n",
"operation PrepareState3 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -499,7 +499,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T4_PrepareState4_Test\n",
"%kata T4_PrepareState4\n",
"\n",
"operation PrepareState4 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",

Просмотреть файл

@ -31,22 +31,22 @@ namespace Quantum.Kata.MultiQubitSystems {
}
@Test("QuantumSimulator")
operation T1_PrepareState1_Test () : Unit {
operation T1_PrepareState1 () : Unit {
AssertEqualOnZeroState(PrepareState1, PrepareState1_Reference);
}
@Test("QuantumSimulator")
operation T2_PrepareState2_Test () : Unit {
operation T2_PrepareState2 () : Unit {
AssertEqualOnZeroState(PrepareState2, PrepareState2_Reference);
}
@Test("QuantumSimulator")
operation T3_PrepareState3_Test () : Unit {
operation T3_PrepareState3 () : Unit {
AssertEqualOnZeroState(PrepareState3, PrepareState3_Reference);
}
@Test("QuantumSimulator")
operation T4_PrepareState4_Test () : Unit {
operation T4_PrepareState4 () : Unit {
AssertEqualOnZeroState(PrepareState4, PrepareState4_Reference);
}
}

Просмотреть файл

@ -135,7 +135,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T1_PrepareState1_Test\n",
"%kata T1_PrepareState1\n",
"\n",
"operation PrepareState1 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" X(qs[0]);\n",
@ -188,7 +188,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T2_PrepareState2_Test\n",
"%kata T2_PrepareState2\n",
"\n",
"operation PrepareState2 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" X(qs[1]);\n",
@ -237,7 +237,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T3_PrepareState3_Test\n",
"%kata T3_PrepareState3\n",
"\n",
"operation PrepareState3 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" H(qs[0]);\n",
@ -298,7 +298,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T4_PrepareState4_Test\n",
"%kata T4_PrepareState4\n",
"\n",
"operation PrepareState4 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" H(qs[0]);\n",

Просмотреть файл

@ -68,7 +68,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T1_RandomBit_Test\n",
"%kata T1_RandomBit\n",
"\n",
"operation RandomBit () : Int {\n",
" using (q = Qubit()) {\n",
@ -104,7 +104,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T2_RandomTwoBits_Test\n",
"%kata T2_RandomTwoBits\n",
"\n",
"operation RandomTwoBits () : Int {\n",
" // ...\n",
@ -140,7 +140,7 @@
},
"outputs": [],
"source": [
"%kata T3_RandomNBits_Test \n",
"%kata T3_RandomNBits \n",
"\n",
"operation RandomNBits (N : Int) : Int {\n",
" // ...\n",
@ -175,7 +175,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T4_WeightedRandomBit_Test\n",
"%kata T4_WeightedRandomBit\n",
"\n",
"operation WeightedRandomBit (x : Double) : Int {\n",
" // ...\n",

Просмотреть файл

@ -18,7 +18,7 @@ namespace Quantum.Kata.RandomNumberGeneration {
// Exercise 1.
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T1_RandomBit_Test () : Unit {
operation T1_RandomBit () : Unit {
Message("Testing...");
CheckFlatDistribution(RandomBit_Wrapper, 1, 0.4, 0.6, 1000, 450);
}
@ -29,7 +29,7 @@ namespace Quantum.Kata.RandomNumberGeneration {
// Exercise 2.
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T2_RandomTwoBits_Test () : Unit {
operation T2_RandomTwoBits () : Unit {
Message("Testing...");
CheckFlatDistribution(RandomTwoBits_Wrapper, 2, 1.4, 1.6, 1000, 200);
}
@ -40,7 +40,7 @@ namespace Quantum.Kata.RandomNumberGeneration {
// Exercise 3.
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T3_RandomNBits_Test () : Unit {
operation T3_RandomNBits () : Unit {
Message("Testing N = 1...");
CheckFlatDistribution(RandomNBits, 1, 0.4, 0.6, 1000, 450);
Message("Testing N = 2...");
@ -111,7 +111,7 @@ namespace Quantum.Kata.RandomNumberGeneration {
// Exercise 4.
@Test("Microsoft.Quantum.Katas.CounterSimulator")
operation T4_WeightedRandomBit_Test () : Unit {
operation T4_WeightedRandomBit () : Unit {
ResetOracleCallsCount();
CheckXPercentZero(0.0);
CheckXPercentZero(0.25);

Просмотреть файл

@ -438,7 +438,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T1_ApplyY_Test\n",
"%kata T1_ApplyY\n",
"\n",
"operation ApplyY (q : Qubit) : Unit is Adj+Ctl {\n",
" // Fill in your code here, then run the cell to test your work.\n",
@ -471,7 +471,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T2_GlobalPhaseI_Test\n",
"%kata T2_GlobalPhaseI\n",
"\n",
"operation GlobalPhaseI (q : Qubit) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -510,7 +510,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T3_SignFlipOnZero_Test\n",
"%kata T3_SignFlipOnZero\n",
"\n",
"operation SignFlipOnZero (q : Qubit) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -615,7 +615,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T4_PrepareMinus_Test\n",
"%kata T4_PrepareMinus\n",
"\n",
"operation PrepareMinus (q : Qubit) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -705,7 +705,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T5_ThreeQuatersPiPhase_Test\n",
"%kata T5_ThreeQuatersPiPhase\n",
"\n",
"operation ThreeQuatersPiPhase (q : Qubit) : Unit is Adj+Ctl {\n",
" // ...\n",
@ -822,7 +822,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T6_PrepareRotatedState_Test\n",
"%kata T6_PrepareRotatedState\n",
"\n",
"open Microsoft.Quantum.Math;\n",
"\n",
@ -862,7 +862,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T7_PrepareArbitraryState_Test\n",
"%kata T7_PrepareArbitraryState\n",
"\n",
"open Microsoft.Quantum.Math;\n",
"\n",

Просмотреть файл

@ -48,37 +48,37 @@ namespace Quantum.Kata.SingleQubitGates {
// Exercise 1.
@Test("QuantumSimulator")
operation T1_ApplyY_Test () : Unit {
operation T1_ApplyY () : Unit {
AssertOperationsEqualReferenced(2, ControlledArrayWrapperOperation(ApplyY, _), ControlledArrayWrapperOperation(Y, _));
}
// Exercise 2.
@Test("QuantumSimulator")
operation T2_GlobalPhaseI_Test () : Unit {
operation T2_GlobalPhaseI () : Unit {
AssertOperationsEqualReferenced(2, ControlledArrayWrapperOperation(GlobalPhaseI, _), ControlledArrayWrapperOperation(GlobalPhaseI_Reference, _));
}
// Exercise 3.
@Test("QuantumSimulator")
operation T3_SignFlipOnZero_Test () : Unit {
operation T3_SignFlipOnZero () : Unit {
AssertOperationsEqualReferenced(2, ControlledArrayWrapperOperation(SignFlipOnZero, _), ControlledArrayWrapperOperation(SignFlipOnZero_Reference, _));
}
// Exercise 4.
@Test("QuantumSimulator")
operation T4_PrepareMinus_Test () : Unit {
operation T4_PrepareMinus () : Unit {
AssertEqualOnZeroState(PrepareMinus, PrepareMinus_Reference);
}
// Exercise 5.
@Test("QuantumSimulator")
operation T5_ThreeQuatersPiPhase_Test () : Unit {
operation T5_ThreeQuatersPiPhase () : Unit {
AssertOperationsEqualReferenced(2, ControlledArrayWrapperOperation(ThreeQuatersPiPhase, _), ControlledArrayWrapperOperation(ThreeQuatersPiPhase_Reference, _));
}
// Exercise 6.
@Test("QuantumSimulator")
operation T6_PrepareRotatedState_Test () : Unit {
operation T6_PrepareRotatedState () : Unit {
for (i in 0 .. 10) {
AssertEqualOnZeroState(PrepareRotatedState(Cos(IntAsDouble(i)), Sin(IntAsDouble(i)), _),
PrepareRotatedState_Reference(Cos(IntAsDouble(i)), Sin(IntAsDouble(i)), _));
@ -87,7 +87,7 @@ namespace Quantum.Kata.SingleQubitGates {
// Exercise 7.
@Test("QuantumSimulator")
operation T7_PrepareArbitraryState_Test () : Unit {
operation T7_PrepareArbitraryState () : Unit {
for (i in 0 .. 10) {
for (j in 0 .. 10) {
AssertEqualOnZeroState(PrepareArbitraryState(Cos(IntAsDouble(i)), Sin(IntAsDouble(i)), IntAsDouble(j), _),

Просмотреть файл

@ -52,7 +52,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T1_ApplyY_Test\n",
"%kata T1_ApplyY\n",
"\n",
"operation ApplyY (q : Qubit) : Unit is Adj+Ctl {\n",
" Y(q); // As simple as that\n",
@ -97,7 +97,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T2_GlobalPhaseI_Test\n",
"%kata T2_GlobalPhaseI\n",
"\n",
"operation GlobalPhaseI (q : Qubit) : Unit is Adj+Ctl {\n",
" Z(q);\n",
@ -146,7 +146,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T3_SignFlipOnZero_Test\n",
"%kata T3_SignFlipOnZero\n",
"\n",
"operation SignFlipOnZero (q : Qubit) : Unit is Adj+Ctl {\n",
" X(q); // Flip the qubit\n",
@ -189,7 +189,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T4_PrepareMinus_Test\n",
"%kata T4_PrepareMinus\n",
"\n",
"operation PrepareMinus (q : Qubit) : Unit is Adj+Ctl {\n",
" X(q); // Turn |0> into |1>\n",
@ -238,7 +238,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T5_ThreeQuatersPiPhase_Test\n",
"%kata T5_ThreeQuatersPiPhase\n",
"\n",
"operation ThreeQuatersPiPhase (q : Qubit) : Unit is Adj+Ctl {\n",
" S(q);\n",
@ -288,7 +288,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T6_PrepareRotatedState_Test\n",
"%kata T6_PrepareRotatedState\n",
"\n",
"open Microsoft.Quantum.Math;\n",
"\n",
@ -352,7 +352,7 @@
"metadata": {},
"outputs": [],
"source": [
"%kata T7_PrepareArbitraryState_Test\n",
"%kata T7_PrepareArbitraryState\n",
"\n",
"open Microsoft.Quantum.Math;\n",
"\n",

Просмотреть файл

@ -33,7 +33,7 @@ namespace Microsoft.Quantum.Katas
{
"To check a test called `Test`:\n" +
"```\n" +
"In []: %check_kata T101_StateFlip_Test \n",
"In []: %check_kata T101_StateFlip \n",
" ...: operation StateFlip (q : Qubit) : Unit is Adj + Ctl {\n",
" // The Pauli X gate will change the |0⟩ state to the |1⟩ state and vice versa.\n",
" // Type X(q);\n",

Просмотреть файл

@ -31,7 +31,7 @@ namespace Microsoft.Quantum.Katas
{
"To run a test called `Test`:\n" +
"```\n" +
"In []: %kata T101_StateFlip_Test \n",
"In []: %kata T101_StateFlip \n",
" ...: operation StateFlip (q : Qubit) : Unit is Adj + Ctl {\n",
" // The Pauli X gate will change the |0⟩ state to the |1⟩ state and vice versa.\n",
" // Type X(q);\n",