From bb512cb7bcfedceaa2cb4baaeaf1c40c12c301c2 Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Mon, 15 Jun 2020 12:24:08 -0700 Subject: [PATCH 1/5] Refactor QSharp.Core into Foundation + Core --- Simulation.sln | 22 ++++ build/pack.ps1 | 1 + .../EntryPointDriver.Tests/Tests.fs | 1 + src/Simulation/QsharpCore/Intrinsic.qs | 107 +----------------- .../Microsoft.Quantum.QSharp.Core.csproj | 1 + src/Simulation/QsharpFoundation/Assert.qs | 68 +++++++++++ .../Bitwise/Bitwise.cs | 0 .../Bitwise/Bitwise.qs | 0 .../Bitwise/Deprecated.qs | 0 .../Convert/Convert.cs | 0 .../Convert/Convert.qs | 0 .../Convert/Deprecated.qs | 0 .../{QsharpCore => QsharpFoundation}/Core.cs | 0 .../{QsharpCore => QsharpFoundation}/Core.qs | 0 .../Environment.qs | 0 .../Math/Constants.qs | 0 .../Math/Deprecated.qs | 0 .../Math/Math.cs | 0 .../Math/Math.qs | 0 .../Math/Trig.qs | 0 .../Math/Types.qs | 0 ...Microsoft.Quantum.QSharp.Foundation.csproj | 40 +++++++ .../Statements/Allocate.cs | 0 .../Statements/Borrow.cs | 0 .../Statements/Release.cs | 0 .../Statements/Return.cs | 0 src/Simulation/QsharpFoundation/Utils.qs | 40 +++++++ 27 files changed, 174 insertions(+), 106 deletions(-) create mode 100644 src/Simulation/QsharpFoundation/Assert.qs rename src/Simulation/{QsharpCore => QsharpFoundation}/Bitwise/Bitwise.cs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Bitwise/Bitwise.qs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Bitwise/Deprecated.qs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Convert/Convert.cs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Convert/Convert.qs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Convert/Deprecated.qs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Core.cs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Core.qs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Environment.qs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Math/Constants.qs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Math/Deprecated.qs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Math/Math.cs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Math/Math.qs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Math/Trig.qs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Math/Types.qs (100%) create mode 100644 src/Simulation/QsharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj rename src/Simulation/{QsharpCore => QsharpFoundation}/Statements/Allocate.cs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Statements/Borrow.cs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Statements/Release.cs (100%) rename src/Simulation/{QsharpCore => QsharpFoundation}/Statements/Return.cs (100%) create mode 100644 src/Simulation/QsharpFoundation/Utils.qs diff --git a/Simulation.sln b/Simulation.sln index 7886189c882..b5574a92069 100644 --- a/Simulation.sln +++ b/Simulation.sln @@ -57,6 +57,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library2", "src\Simulation\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "src\Simulation\Simulators.Tests\TestProjects\UnitTests\UnitTests.csproj", "{46278108-D247-4EFC-AC34-23D4A676F62F}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "simulation", "simulation", "{A50D5CD0-FA72-48EF-AC24-F41FB8205DAE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Quantum.QSharp.Foundation", "src\Simulation\QsharpFoundation\Microsoft.Quantum.QSharp.Foundation.csproj", "{7E873A90-5291-4DB7-AE87-E75EA904E284}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -389,6 +393,22 @@ Global {46278108-D247-4EFC-AC34-23D4A676F62F}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU {46278108-D247-4EFC-AC34-23D4A676F62F}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU {46278108-D247-4EFC-AC34-23D4A676F62F}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.Debug|x64.ActiveCfg = Debug|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.Debug|x64.Build.0 = Debug|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.Release|Any CPU.Build.0 = Release|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.Release|x64.ActiveCfg = Release|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.Release|x64.Build.0 = Release|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {7E873A90-5291-4DB7-AE87-E75EA904E284}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -416,6 +436,8 @@ Global {7256B986-6705-42FC-9F57-485D72D9DE51} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} {A85277B3-4E07-4E15-8F0C-07CC855A3BCB} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} {46278108-D247-4EFC-AC34-23D4A676F62F} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} + {A50D5CD0-FA72-48EF-AC24-F41FB8205DAE} = {99E234BC-997E-4E63-9F5C-3C3977543404} + {7E873A90-5291-4DB7-AE87-E75EA904E284} = {A50D5CD0-FA72-48EF-AC24-F41FB8205DAE} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {929C0464-86D8-4F70-8835-0A5EAF930821} diff --git a/build/pack.ps1 b/build/pack.ps1 index 893db2b5728..412902b3617 100644 --- a/build/pack.ps1 +++ b/build/pack.ps1 @@ -63,6 +63,7 @@ Pack-Dotnet '../src/Azure/Azure.Quantum.Client/Microsoft.Azure.Quantum.Client.cs Pack-One '../src/Simulation/CsharpGeneration/Microsoft.Quantum.CsharpGeneration.fsproj' '-IncludeReferencedProjects' Pack-Dotnet '../src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj' Pack-Dotnet '../src/Simulation/Core/Microsoft.Quantum.Runtime.Core.csproj' +Pack-Dotnet '../src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj' Pack-Dotnet '../src/Simulation/QsharpCore/Microsoft.Quantum.QSharp.Core.csproj' Pack-One '../src/Simulation/Simulators/Microsoft.Quantum.Simulators.nuspec' Pack-One '../src/Quantum.Development.Kit/Microsoft.Quantum.Development.Kit.nuspec' diff --git a/src/Simulation/EntryPointDriver.Tests/Tests.fs b/src/Simulation/EntryPointDriver.Tests/Tests.fs index 57f283a2d73..32e649eedd7 100644 --- a/src/Simulation/EntryPointDriver.Tests/Tests.fs +++ b/src/Simulation/EntryPointDriver.Tests/Tests.fs @@ -96,6 +96,7 @@ let private compileCsharp (sources : string seq) = "System.Runtime.Extensions" "System.Runtime.Numerics" "Microsoft.Quantum.EntryPointDriver" + "Microsoft.Quantum.QSharp.Foundation" "Microsoft.Quantum.QSharp.Core" "Microsoft.Quantum.QsDataStructures" "Microsoft.Quantum.Runtime.Core" diff --git a/src/Simulation/QsharpCore/Intrinsic.qs b/src/Simulation/QsharpCore/Intrinsic.qs index 28f0353dd86..1785a587c71 100644 --- a/src/Simulation/QsharpCore/Intrinsic.qs +++ b/src/Simulation/QsharpCore/Intrinsic.qs @@ -5,108 +5,6 @@ namespace Microsoft.Quantum.Intrinsic { open Microsoft.Quantum.Math; open Microsoft.Quantum.Convert; - /// # Summary - /// The random operation takes an array of doubles as input, and returns - /// a randomly-selected index into the array as an `Int`. - /// The probability of selecting a specific index is proportional to the value - /// of the array element at that index. - /// Array elements that are equal to zero are ignored and their indices are never - /// returned. If any array element is less than zero, - /// or if no array element is greater than zero, then the operation fails. - /// - /// # Input - /// ## probs - /// An array of floating-point numbers proportional to the probability of - /// selecting each index. - /// - /// # Output - /// An integer $i$ with probability $\Pr(i) = p_i / \sum_i p_i$, where $p_i$ - /// is the $i$th element of `probs`. - operation Random (probs : Double[]) : Int { - body intrinsic; - } - - - /// # Summary - /// Asserts that measuring the given qubits in the given Pauli basis will - /// always have the given result. - /// - /// # Input - /// ## bases - /// A measurement effect to assert the probability of, expressed as a - /// multi-qubit Pauli operator. - /// ## qubits - /// A register on which to make the assertion. - /// ## result - /// The expected result of `Measure(bases, qubits)`. - /// ## msg - /// A message to be reported if the assertion fails. - /// - /// # Remarks - /// Note that the Adjoint and Controlled versions of this operation will not - /// check the condition. - /// - /// # See Also - /// - AssertProb - operation Assert (bases : Pauli[], qubits : Qubit[], result : Result, msg : String) : Unit - is Adj + Ctl { - body intrinsic; - } - - - /// # Summary - /// Asserts that measuring the given qubits in the given Pauli basis will have the given result - /// with the given probability, within some tolerance. - /// - /// # Input - /// ## bases - /// A measurement effect to assert the probability of, expressed as a - /// multi-qubit Pauli operator. - /// ## qubits - /// A register on which to make the assertion. - /// ## result - /// An expected result of `Measure(bases, qubits)`. - /// ## prob - /// The probability with which the given result is expected. - /// ## msg - /// A message to be reported if the assertion fails. - /// - /// # Example - /// ```qsharp - /// using (register = Qubit()) { - /// H(register); - /// AssertProb([PauliZ], [register], One, 0.5, - /// "Measuring in conjugate basis did not give 50/50 results.", 1e-5); - /// } - /// ``` - /// - /// # Remarks - /// Note that the Adjoint and Controlled versions of this operation will not - /// check the condition. - /// - /// # See Also - /// - Assert - operation AssertProb (bases : Pauli[], qubits : Qubit[], result : Result, prob : Double, msg : String, tol : Double) : Unit - is Adj + Ctl { - body intrinsic; - } - - - /// # Summary - /// Logs a message. - /// - /// # Input - /// ## msg - /// The message to be reported. - /// - /// # Remarks - /// The specific behavior of this function is simulator-dependent, - /// but in most cases the given message will be written to the console. - function Message (msg : String) : Unit { - body intrinsic; - } - - //------------------------------------------------- // Clifford and related operations //------------------------------------------------- @@ -118,10 +16,7 @@ namespace Microsoft.Quantum.Intrinsic { /// This is a no-op. It is provided for completeness and because /// sometimes it is useful to call the identity in an algorithm or to pass it as a parameter. operation I (target : Qubit) : Unit - is Adj + Ctl { - body (...) { } - adjoint self; - } + is Adj + Ctl { } /// # Summary diff --git a/src/Simulation/QsharpCore/Microsoft.Quantum.QSharp.Core.csproj b/src/Simulation/QsharpCore/Microsoft.Quantum.QSharp.Core.csproj index 6fa6d8bc6a1..b3d43b00f52 100644 --- a/src/Simulation/QsharpCore/Microsoft.Quantum.QSharp.Core.csproj +++ b/src/Simulation/QsharpCore/Microsoft.Quantum.QSharp.Core.csproj @@ -27,6 +27,7 @@ + diff --git a/src/Simulation/QsharpFoundation/Assert.qs b/src/Simulation/QsharpFoundation/Assert.qs new file mode 100644 index 00000000000..6f36ade4d6b --- /dev/null +++ b/src/Simulation/QsharpFoundation/Assert.qs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + /// # Summary + /// Asserts that measuring the given qubits in the given Pauli basis will + /// always have the given result. + /// + /// # Input + /// ## bases + /// A measurement effect to assert the probability of, expressed as a + /// multi-qubit Pauli operator. + /// ## qubits + /// A register on which to make the assertion. + /// ## result + /// The expected result of `Measure(bases, qubits)`. + /// ## msg + /// A message to be reported if the assertion fails. + /// + /// # Remarks + /// Note that the Adjoint and Controlled versions of this operation will not + /// check the condition. + /// + /// # See Also + /// - AssertProb + operation Assert (bases : Pauli[], qubits : Qubit[], result : Result, msg : String) : Unit + is Adj + Ctl { + body intrinsic; + } + + + /// # Summary + /// Asserts that measuring the given qubits in the given Pauli basis will have the given result + /// with the given probability, within some tolerance. + /// + /// # Input + /// ## bases + /// A measurement effect to assert the probability of, expressed as a + /// multi-qubit Pauli operator. + /// ## qubits + /// A register on which to make the assertion. + /// ## result + /// An expected result of `Measure(bases, qubits)`. + /// ## prob + /// The probability with which the given result is expected. + /// ## msg + /// A message to be reported if the assertion fails. + /// + /// # Example + /// ```qsharp + /// using (register = Qubit()) { + /// H(register); + /// AssertProb([PauliZ], [register], One, 0.5, + /// "Measuring in conjugate basis did not give 50/50 results.", 1e-5); + /// } + /// ``` + /// + /// # Remarks + /// Note that the Adjoint and Controlled versions of this operation will not + /// check the condition. + /// + /// # See Also + /// - Assert + operation AssertProb (bases : Pauli[], qubits : Qubit[], result : Result, prob : Double, msg : String, tol : Double) : Unit + is Adj + Ctl { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/QsharpCore/Bitwise/Bitwise.cs b/src/Simulation/QsharpFoundation/Bitwise/Bitwise.cs similarity index 100% rename from src/Simulation/QsharpCore/Bitwise/Bitwise.cs rename to src/Simulation/QsharpFoundation/Bitwise/Bitwise.cs diff --git a/src/Simulation/QsharpCore/Bitwise/Bitwise.qs b/src/Simulation/QsharpFoundation/Bitwise/Bitwise.qs similarity index 100% rename from src/Simulation/QsharpCore/Bitwise/Bitwise.qs rename to src/Simulation/QsharpFoundation/Bitwise/Bitwise.qs diff --git a/src/Simulation/QsharpCore/Bitwise/Deprecated.qs b/src/Simulation/QsharpFoundation/Bitwise/Deprecated.qs similarity index 100% rename from src/Simulation/QsharpCore/Bitwise/Deprecated.qs rename to src/Simulation/QsharpFoundation/Bitwise/Deprecated.qs diff --git a/src/Simulation/QsharpCore/Convert/Convert.cs b/src/Simulation/QsharpFoundation/Convert/Convert.cs similarity index 100% rename from src/Simulation/QsharpCore/Convert/Convert.cs rename to src/Simulation/QsharpFoundation/Convert/Convert.cs diff --git a/src/Simulation/QsharpCore/Convert/Convert.qs b/src/Simulation/QsharpFoundation/Convert/Convert.qs similarity index 100% rename from src/Simulation/QsharpCore/Convert/Convert.qs rename to src/Simulation/QsharpFoundation/Convert/Convert.qs diff --git a/src/Simulation/QsharpCore/Convert/Deprecated.qs b/src/Simulation/QsharpFoundation/Convert/Deprecated.qs similarity index 100% rename from src/Simulation/QsharpCore/Convert/Deprecated.qs rename to src/Simulation/QsharpFoundation/Convert/Deprecated.qs diff --git a/src/Simulation/QsharpCore/Core.cs b/src/Simulation/QsharpFoundation/Core.cs similarity index 100% rename from src/Simulation/QsharpCore/Core.cs rename to src/Simulation/QsharpFoundation/Core.cs diff --git a/src/Simulation/QsharpCore/Core.qs b/src/Simulation/QsharpFoundation/Core.qs similarity index 100% rename from src/Simulation/QsharpCore/Core.qs rename to src/Simulation/QsharpFoundation/Core.qs diff --git a/src/Simulation/QsharpCore/Environment.qs b/src/Simulation/QsharpFoundation/Environment.qs similarity index 100% rename from src/Simulation/QsharpCore/Environment.qs rename to src/Simulation/QsharpFoundation/Environment.qs diff --git a/src/Simulation/QsharpCore/Math/Constants.qs b/src/Simulation/QsharpFoundation/Math/Constants.qs similarity index 100% rename from src/Simulation/QsharpCore/Math/Constants.qs rename to src/Simulation/QsharpFoundation/Math/Constants.qs diff --git a/src/Simulation/QsharpCore/Math/Deprecated.qs b/src/Simulation/QsharpFoundation/Math/Deprecated.qs similarity index 100% rename from src/Simulation/QsharpCore/Math/Deprecated.qs rename to src/Simulation/QsharpFoundation/Math/Deprecated.qs diff --git a/src/Simulation/QsharpCore/Math/Math.cs b/src/Simulation/QsharpFoundation/Math/Math.cs similarity index 100% rename from src/Simulation/QsharpCore/Math/Math.cs rename to src/Simulation/QsharpFoundation/Math/Math.cs diff --git a/src/Simulation/QsharpCore/Math/Math.qs b/src/Simulation/QsharpFoundation/Math/Math.qs similarity index 100% rename from src/Simulation/QsharpCore/Math/Math.qs rename to src/Simulation/QsharpFoundation/Math/Math.qs diff --git a/src/Simulation/QsharpCore/Math/Trig.qs b/src/Simulation/QsharpFoundation/Math/Trig.qs similarity index 100% rename from src/Simulation/QsharpCore/Math/Trig.qs rename to src/Simulation/QsharpFoundation/Math/Trig.qs diff --git a/src/Simulation/QsharpCore/Math/Types.qs b/src/Simulation/QsharpFoundation/Math/Types.qs similarity index 100% rename from src/Simulation/QsharpCore/Math/Types.qs rename to src/Simulation/QsharpFoundation/Math/Types.qs diff --git a/src/Simulation/QsharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj b/src/Simulation/QsharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj new file mode 100644 index 00000000000..6c83c7b7c3e --- /dev/null +++ b/src/Simulation/QsharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj @@ -0,0 +1,40 @@ + + + + + + + netstandard2.1 + true + false + false + + + + Microsoft + Base support for the Q# programming language. + See: https://docs.microsoft.com/en-us/quantum/relnotes/ + MIT + https://github.com/microsoft/qsharp-runtime + https://secure.gravatar.com/avatar/bd1f02955b2853ba0a3b1cdc2434e8ec.png + Quantum Q# Qsharp + true + + + + + + + + + + + + + + + + + + + diff --git a/src/Simulation/QsharpCore/Statements/Allocate.cs b/src/Simulation/QsharpFoundation/Statements/Allocate.cs similarity index 100% rename from src/Simulation/QsharpCore/Statements/Allocate.cs rename to src/Simulation/QsharpFoundation/Statements/Allocate.cs diff --git a/src/Simulation/QsharpCore/Statements/Borrow.cs b/src/Simulation/QsharpFoundation/Statements/Borrow.cs similarity index 100% rename from src/Simulation/QsharpCore/Statements/Borrow.cs rename to src/Simulation/QsharpFoundation/Statements/Borrow.cs diff --git a/src/Simulation/QsharpCore/Statements/Release.cs b/src/Simulation/QsharpFoundation/Statements/Release.cs similarity index 100% rename from src/Simulation/QsharpCore/Statements/Release.cs rename to src/Simulation/QsharpFoundation/Statements/Release.cs diff --git a/src/Simulation/QsharpCore/Statements/Return.cs b/src/Simulation/QsharpFoundation/Statements/Return.cs similarity index 100% rename from src/Simulation/QsharpCore/Statements/Return.cs rename to src/Simulation/QsharpFoundation/Statements/Return.cs diff --git a/src/Simulation/QsharpFoundation/Utils.qs b/src/Simulation/QsharpFoundation/Utils.qs new file mode 100644 index 00000000000..9104f4596b6 --- /dev/null +++ b/src/Simulation/QsharpFoundation/Utils.qs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + /// # Summary + /// The random operation takes an array of doubles as input, and returns + /// a randomly-selected index into the array as an `Int`. + /// The probability of selecting a specific index is proportional to the value + /// of the array element at that index. + /// Array elements that are equal to zero are ignored and their indices are never + /// returned. If any array element is less than zero, + /// or if no array element is greater than zero, then the operation fails. + /// + /// # Input + /// ## probs + /// An array of floating-point numbers proportional to the probability of + /// selecting each index. + /// + /// # Output + /// An integer $i$ with probability $\Pr(i) = p_i / \sum_i p_i$, where $p_i$ + /// is the $i$th element of `probs`. + operation Random(probs : Double[]) : Int { + body intrinsic; + } + + /// # Summary + /// Logs a message. + /// + /// # Input + /// ## msg + /// The message to be reported. + /// + /// # Remarks + /// The specific behavior of this function is simulator-dependent, + /// but in most cases the given message will be written to the console. + function Message(msg : String) : Unit { + body intrinsic; + } + +} \ No newline at end of file From a54fa33bac0c3dff9e975f025f7f8c7e552b543c Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Mon, 15 Jun 2020 15:15:30 -0700 Subject: [PATCH 2/5] Trying to fix sln --- Simulation.sln | 40 +++++++++---------- .../Microsoft.Quantum.QSharp.Core.csproj | 2 +- ...Microsoft.Quantum.QSharp.Foundation.csproj | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Simulation.sln b/Simulation.sln index b5574a92069..e85b15b0d8a 100644 --- a/Simulation.sln +++ b/Simulation.sln @@ -57,9 +57,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library2", "src\Simulation\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "src\Simulation\Simulators.Tests\TestProjects\UnitTests\UnitTests.csproj", "{46278108-D247-4EFC-AC34-23D4A676F62F}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "simulation", "simulation", "{A50D5CD0-FA72-48EF-AC24-F41FB8205DAE}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Simulation", "Simulation", "{652D1D9B-234B-4DBF-9971-34F866AE58BA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Quantum.QSharp.Foundation", "src\Simulation\QsharpFoundation\Microsoft.Quantum.QSharp.Foundation.csproj", "{7E873A90-5291-4DB7-AE87-E75EA904E284}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Quantum.QSharp.Foundation", "src\Simulation\QsharpFoundation\Microsoft.Quantum.QSharp.Foundation.csproj", "{8D993092-F295-41A3-B1D0-DD5EAFA17B8F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -393,22 +393,22 @@ Global {46278108-D247-4EFC-AC34-23D4A676F62F}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU {46278108-D247-4EFC-AC34-23D4A676F62F}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU {46278108-D247-4EFC-AC34-23D4A676F62F}.RelWithDebInfo|x64.Build.0 = Release|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.Debug|x64.ActiveCfg = Debug|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.Debug|x64.Build.0 = Debug|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.MinSizeRel|x64.Build.0 = Debug|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.Release|Any CPU.Build.0 = Release|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.Release|x64.ActiveCfg = Release|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.Release|x64.Build.0 = Release|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU - {7E873A90-5291-4DB7-AE87-E75EA904E284}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Debug|x64.ActiveCfg = Debug|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Debug|x64.Build.0 = Debug|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Release|Any CPU.Build.0 = Release|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Release|x64.ActiveCfg = Release|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.Release|x64.Build.0 = Release|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -436,8 +436,8 @@ Global {7256B986-6705-42FC-9F57-485D72D9DE51} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} {A85277B3-4E07-4E15-8F0C-07CC855A3BCB} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} {46278108-D247-4EFC-AC34-23D4A676F62F} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820} - {A50D5CD0-FA72-48EF-AC24-F41FB8205DAE} = {99E234BC-997E-4E63-9F5C-3C3977543404} - {7E873A90-5291-4DB7-AE87-E75EA904E284} = {A50D5CD0-FA72-48EF-AC24-F41FB8205DAE} + {652D1D9B-234B-4DBF-9971-34F866AE58BA} = {99E234BC-997E-4E63-9F5C-3C3977543404} + {8D993092-F295-41A3-B1D0-DD5EAFA17B8F} = {652D1D9B-234B-4DBF-9971-34F866AE58BA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {929C0464-86D8-4F70-8835-0A5EAF930821} diff --git a/src/Simulation/QsharpCore/Microsoft.Quantum.QSharp.Core.csproj b/src/Simulation/QsharpCore/Microsoft.Quantum.QSharp.Core.csproj index b3d43b00f52..621f0ebc169 100644 --- a/src/Simulation/QsharpCore/Microsoft.Quantum.QSharp.Core.csproj +++ b/src/Simulation/QsharpCore/Microsoft.Quantum.QSharp.Core.csproj @@ -27,7 +27,7 @@ - + diff --git a/src/Simulation/QsharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj b/src/Simulation/QsharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj index 6c83c7b7c3e..ccb777f1fd8 100644 --- a/src/Simulation/QsharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj +++ b/src/Simulation/QsharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj @@ -12,7 +12,7 @@ Microsoft - Base support for the Q# programming language. + Foundation implementation for the Q# programming language. See: https://docs.microsoft.com/en-us/quantum/relnotes/ MIT https://github.com/microsoft/qsharp-runtime From 856a1df4b0aae99fa0a309f1f2ecc44a04a5515b Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Tue, 16 Jun 2020 12:01:18 -0700 Subject: [PATCH 3/5] Splitting Utils.qs --- src/Simulation/QsharpFoundation/Message.qs | 18 ++++++++++++++++++ .../QsharpFoundation/{Utils.qs => Random.qs} | 15 --------------- 2 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 src/Simulation/QsharpFoundation/Message.qs rename src/Simulation/QsharpFoundation/{Utils.qs => Random.qs} (73%) diff --git a/src/Simulation/QsharpFoundation/Message.qs b/src/Simulation/QsharpFoundation/Message.qs new file mode 100644 index 00000000000..5ae8f8c2cfb --- /dev/null +++ b/src/Simulation/QsharpFoundation/Message.qs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Intrinsic { + /// # Summary + /// Logs a message. + /// + /// # Input + /// ## msg + /// The message to be reported. + /// + /// # Remarks + /// The specific behavior of this function is simulator-dependent, + /// but in most cases the given message will be written to the console. + function Message(msg : String) : Unit { + body intrinsic; + } +} \ No newline at end of file diff --git a/src/Simulation/QsharpFoundation/Utils.qs b/src/Simulation/QsharpFoundation/Random.qs similarity index 73% rename from src/Simulation/QsharpFoundation/Utils.qs rename to src/Simulation/QsharpFoundation/Random.qs index 9104f4596b6..b43b0c7fb5a 100644 --- a/src/Simulation/QsharpFoundation/Utils.qs +++ b/src/Simulation/QsharpFoundation/Random.qs @@ -22,19 +22,4 @@ namespace Microsoft.Quantum.Intrinsic { operation Random(probs : Double[]) : Int { body intrinsic; } - - /// # Summary - /// Logs a message. - /// - /// # Input - /// ## msg - /// The message to be reported. - /// - /// # Remarks - /// The specific behavior of this function is simulator-dependent, - /// but in most cases the given message will be written to the console. - function Message(msg : String) : Unit { - body intrinsic; - } - } \ No newline at end of file From 8eeb0219b3383b18167619200545fe151d2d3322 Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Tue, 16 Jun 2020 12:18:18 -0700 Subject: [PATCH 4/5] Moving ClassicalControl.qs --- .../{QsharpCore => QsharpFoundation}/ClassicalControl.qs | 2 -- 1 file changed, 2 deletions(-) rename src/Simulation/{QsharpCore => QsharpFoundation}/ClassicalControl.qs (99%) diff --git a/src/Simulation/QsharpCore/ClassicalControl.qs b/src/Simulation/QsharpFoundation/ClassicalControl.qs similarity index 99% rename from src/Simulation/QsharpCore/ClassicalControl.qs rename to src/Simulation/QsharpFoundation/ClassicalControl.qs index f26320286bc..05ea7392569 100644 --- a/src/Simulation/QsharpCore/ClassicalControl.qs +++ b/src/Simulation/QsharpFoundation/ClassicalControl.qs @@ -3,8 +3,6 @@ namespace Microsoft.Quantum.Simulation.QuantumProcessor.Extensions //ToDo: update namespace to a more appropriate name { - open Microsoft.Quantum.Intrinsic; - operation NoOp() : Unit is Ctl + Adj {} // Private helper operations. From c01e9b55b5cdd437d1289a2a593f880a1802508a Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Tue, 16 Jun 2020 13:43:23 -0700 Subject: [PATCH 5/5] Reverting Intrinsic.I change --- src/Simulation/QsharpCore/Intrinsic.qs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Simulation/QsharpCore/Intrinsic.qs b/src/Simulation/QsharpCore/Intrinsic.qs index 1785a587c71..5ed04498990 100644 --- a/src/Simulation/QsharpCore/Intrinsic.qs +++ b/src/Simulation/QsharpCore/Intrinsic.qs @@ -16,7 +16,10 @@ namespace Microsoft.Quantum.Intrinsic { /// This is a no-op. It is provided for completeness and because /// sometimes it is useful to call the identity in an algorithm or to pass it as a parameter. operation I (target : Qubit) : Unit - is Adj + Ctl { } + is Adj + Ctl { + body (...) { } + adjoint self; + } /// # Summary