From ce387a45490e6ca7d4680ff06cffdd48ad9042e4 Mon Sep 17 00:00:00 2001
From: Christopher Granade <cgranade@cgranade.com>
Date: Mon, 13 Jan 2020 12:03:11 -0800
Subject: [PATCH 1/4] Add new MeasureIfAllZeros operation.

---
 Standard/src/Measurement/Registers.qs       | 23 +++++++++++++++++++++
 Standard/tests/Measurement/RegisterTests.qs | 22 ++++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 Standard/tests/Measurement/RegisterTests.qs

diff --git a/Standard/src/Measurement/Registers.qs b/Standard/src/Measurement/Registers.qs
index e3b3e515af9..e2754072911 100644
--- a/Standard/src/Measurement/Registers.qs
+++ b/Standard/src/Measurement/Registers.qs
@@ -72,4 +72,27 @@ namespace Microsoft.Quantum.Measurement {
         return ForEach(M, targets);
     }
 
+    /// # Summary
+    /// Measures a register of qubits is in the all-zeros state.
+    ///
+    /// # Description
+    /// Given a register of qubits, measures if that register is in the state
+    /// $\ket{00 \cdots 0}$ by performing a computational basis (i.e.:
+    /// `PauliZ`) measurement on each individual qubit in the register.
+    ///
+    /// # Input
+    /// ## register
+    /// The register of qubits to be measured.
+    ///
+    /// # Output
+    /// `true` if and only if the register is measured to be in the
+    /// $\ket{00 \cdots 0}$ state.
+    ///
+    /// # Remarks
+    /// This operation does not reset its qubits, but projects them to a
+    /// computational basis state.
+    operation MeasureIfAllZeros(register : Qubit[]) : Bool {
+        return All(IsResultZero, ForEach(M, register));
+    }
+
 }
diff --git a/Standard/tests/Measurement/RegisterTests.qs b/Standard/tests/Measurement/RegisterTests.qs
new file mode 100644
index 00000000000..b1f970da4fb
--- /dev/null
+++ b/Standard/tests/Measurement/RegisterTests.qs
@@ -0,0 +1,22 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+namespace Microsoft.Quantum.Measurement.Tests {
+    open Microsoft.Quantum.Intrinsic;
+    open Microsoft.Quantum.Canon;
+    open Microsoft.Quantum.Measurement;
+    open Microsoft.Quantum.Diagnostics;
+
+    @Test("QuantumSimulator")
+    operation CheckMeasureIfAllZeros() : Unit {
+        using (qs = Qubit[3]) {
+            Fact(MeasureIfAllZeros(qs));
+
+            X(qs[1]);
+            Fact(not MeasureIfAllZeros(qs));
+
+            ResetAll(qs);
+        }
+    }
+
+}

From 8f34d28c37920041e063f73d62b24c3d22aa2634 Mon Sep 17 00:00:00 2001
From: Christopher Granade <cgranade@cgranade.com>
Date: Mon, 13 Jan 2020 13:16:14 -0800
Subject: [PATCH 2/4] Forgot message.

---
 Standard/tests/Measurement/RegisterTests.qs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Standard/tests/Measurement/RegisterTests.qs b/Standard/tests/Measurement/RegisterTests.qs
index b1f970da4fb..f1e472b9778 100644
--- a/Standard/tests/Measurement/RegisterTests.qs
+++ b/Standard/tests/Measurement/RegisterTests.qs
@@ -10,10 +10,10 @@ namespace Microsoft.Quantum.Measurement.Tests {
     @Test("QuantumSimulator")
     operation CheckMeasureIfAllZeros() : Unit {
         using (qs = Qubit[3]) {
-            Fact(MeasureIfAllZeros(qs));
+            Fact(MeasureIfAllZeros(qs), "MeasureIfAllZeros was false for |000⟩ state.");
 
             X(qs[1]);
-            Fact(not MeasureIfAllZeros(qs));
+            Fact(not MeasureIfAllZeros(qs), "MeasureIfAllZeros was true for |010⟩ state.");
 
             ResetAll(qs);
         }

From 44eb14f482c596e6d0e1411357fb05064a43523e Mon Sep 17 00:00:00 2001
From: Chris Granade <chgranad@microsoft.com>
Date: Wed, 15 Jan 2020 14:15:12 -0800
Subject: [PATCH 3/4] Update Standard/src/Measurement/Registers.qs

Co-Authored-By: Mariia Mykhailova <mamykhai@microsoft.com>
---
 Standard/src/Measurement/Registers.qs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Standard/src/Measurement/Registers.qs b/Standard/src/Measurement/Registers.qs
index e2754072911..0f258e5853b 100644
--- a/Standard/src/Measurement/Registers.qs
+++ b/Standard/src/Measurement/Registers.qs
@@ -73,7 +73,7 @@ namespace Microsoft.Quantum.Measurement {
     }
 
     /// # Summary
-    /// Measures a register of qubits is in the all-zeros state.
+    /// Measures a register of qubits and returns true if it is in the all-zeros state or false otherwise.
     ///
     /// # Description
     /// Given a register of qubits, measures if that register is in the state

From 91df3c918fa18de5f5a285ac902a09a42a10aa54 Mon Sep 17 00:00:00 2001
From: Chris Granade <chgranad@microsoft.com>
Date: Wed, 12 Feb 2020 15:14:36 -0800
Subject: [PATCH 4/4] Update Standard/src/Measurement/Registers.qs

Co-Authored-By: Mariia Mykhailova <mamykhai@microsoft.com>
---
 Standard/src/Measurement/Registers.qs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Standard/src/Measurement/Registers.qs b/Standard/src/Measurement/Registers.qs
index 0f258e5853b..a384c64b15d 100644
--- a/Standard/src/Measurement/Registers.qs
+++ b/Standard/src/Measurement/Registers.qs
@@ -76,7 +76,7 @@ namespace Microsoft.Quantum.Measurement {
     /// Measures a register of qubits and returns true if it is in the all-zeros state or false otherwise.
     ///
     /// # Description
-    /// Given a register of qubits, measures if that register is in the state
+    /// Given a register of qubits, checks if that register is in the state
     /// $\ket{00 \cdots 0}$ by performing a computational basis (i.e.:
     /// `PauliZ`) measurement on each individual qubit in the register.
     ///