diff --git a/library/src/tests/diagnostics.rs b/library/src/tests/diagnostics.rs index f30dfeaa96..d549b1374d 100644 --- a/library/src/tests/diagnostics.rs +++ b/library/src/tests/diagnostics.rs @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -use crate::tests::test_expression_fails; +use crate::tests::{ + test_expression_fails, test_expression_fails_with_lib_and_profile_and_sim, + test_expression_with_lib_and_profile_and_sim, +}; use super::test_expression; use expect_test::expect; -use qsc::interpret::Value; +use qsc::{interpret::Value, target::Profile}; #[test] fn check_operations_are_equal() { @@ -535,6 +538,24 @@ fn check_post_select_collapses_superposition_to_zero() { ); } +#[test] +fn check_post_select_collapses_superposition_to_zero_on_clifford() { + test_expression_with_lib_and_profile_and_sim( + "{ + import Std.Diagnostics.PostSelectZ; + import Std.Diagnostics.CheckZero; + use q = Qubit(); + H(q); + PostSelectZ(Zero, q); + // Qubit must be zero on release. + }", + "", + Profile::Unrestricted, + &mut qsc::CliffordSim::new(1), + &Value::unit(), + ); +} + #[test] fn check_post_select_collapses_superposition_to_one() { test_expression( @@ -552,6 +573,24 @@ fn check_post_select_collapses_superposition_to_one() { ); } +#[test] +fn check_post_select_collapses_superposition_to_one_on_clifford() { + test_expression_with_lib_and_profile_and_sim( + "{ + import Std.Diagnostics.PostSelectZ; + import Std.Diagnostics.CheckZero; + use q = Qubit(); + H(q); + PostSelectZ(One, q); + X(q); // Resets the qubit back to zero for release. + }", + "", + Profile::Unrestricted, + &mut qsc::CliffordSim::new(1), + &Value::unit(), + ); +} + #[test] fn check_post_select_fails_with_non_existent_state() { let err = test_expression_fails( @@ -567,3 +606,22 @@ fn check_post_select_fails_with_non_existent_state() { ] .assert_eq(&err); } + +#[test] +fn check_post_select_fails_with_non_existent_state_on_clifford() { + let err = test_expression_fails_with_lib_and_profile_and_sim( + "{ + import Std.Diagnostics.PostSelectZ; + import Std.Diagnostics.CheckZero; + use q = Qubit(); + PostSelectZ(One, q); + }", + "", + Profile::Unrestricted, + &mut qsc::CliffordSim::new(1), + ); + expect![ + "intrinsic callable `PostSelectZ` failed: post-selection condition has zero probability" + ] + .assert_eq(&err); +} diff --git a/library/std/src/Std/OpenQASM/Intrinsic.qs b/library/std/src/Std/OpenQASM/Intrinsic.qs index ec64de453c..07ec7d3b2b 100644 --- a/library/std/src/Std/OpenQASM/Intrinsic.qs +++ b/library/std/src/Std/OpenQASM/Intrinsic.qs @@ -38,7 +38,7 @@ export rxx, ryy, rzz; // that Qiskit wont emit correctly. export dcx, ecr, r, rzx, cs, csdg, sxdg, csx, rccx, c3sqrtx, c3x, rc3x, xx_minus_yy, xx_plus_yy, ccz; -export mresetz_checked; +export mresetz_checked, postselectz; export __quantum__qis__barrier__body; @@ -647,6 +647,10 @@ operation mresetz_checked(q : Qubit) : Int { } } +operation postselectz(r : Result, q : Qubit) : Unit { + Std.Diagnostics.PostSelectZ(r, q); +} + /// The ``BARRIER`` function is used to implement the `barrier` statement in QASM. /// The `@SimulatableIntrinsic` attribute is used to mark the operation for QIR /// generation. diff --git a/source/compiler/qsc_eval/src/backend.rs b/source/compiler/qsc_eval/src/backend.rs index 3c4ae0e8ee..e1bae4198c 100644 --- a/source/compiler/qsc_eval/src/backend.rs +++ b/source/compiler/qsc_eval/src/backend.rs @@ -1410,7 +1410,7 @@ impl Backend for CliffordSim { Err("adjoint T gate is not supported in Clifford simulation".to_string()) } - fn custom_intrinsic(&mut self, name: &str, _arg: Value) -> Option> { + fn custom_intrinsic(&mut self, name: &str, arg: Value) -> Option> { match name { "BeginEstimateCaching" => Some(Ok(Value::Bool(true))), "GlobalPhase" @@ -1433,9 +1433,14 @@ impl Backend for CliffordSim { "Apply" => Some(Err( "arbitrary unitary application not supported in Clifford simulation".to_string(), )), - "PostSelectZ" => Some(Err( - "post-selection not supported in Clifford simulation".to_string() - )), + "PostSelectZ" => { + let [result, qubit] = unwrap_tuple(arg); + let id = qubit.unwrap_qubit().deref().0; + let Value::Result(val::Result::Val(val)) = result else { + panic!("first argument to PostSelectZ should be a measurement result"); + }; + Some(self.sim.post_select_z(val, id).map(|()| Value::unit())) + } _ => None, } } diff --git a/source/compiler/qsc_fir_transforms/src/defunctionalize/tests/cross_package.rs b/source/compiler/qsc_fir_transforms/src/defunctionalize/tests/cross_package.rs index 49b612b4ef..072edb45d6 100644 --- a/source/compiler/qsc_fir_transforms/src/defunctionalize/tests/cross_package.rs +++ b/source/compiler/qsc_fir_transforms/src/defunctionalize/tests/cross_package.rs @@ -108,14 +108,14 @@ fn analysis_apply_operation_power_ca_consumer() { Adjoint op }; { - let _range_id_48034 : Range = 1..AbsI(power); - mutable _index_id_48037 : Int = _range_id_48034::Start; - let _step_id_48042 : Int = _range_id_48034::Step; - let _end_id_48047 : Int = _range_id_48034::End; - while _step_id_48042 > 0 and _index_id_48037 <= _end_id_48047 or _step_id_48042 < 0 and _index_id_48037 >= _end_id_48047 { - let _ : Int = _index_id_48037; + let _range_id_48050 : Range = 1..AbsI(power); + mutable _index_id_48053 : Int = _range_id_48050::Start; + let _step_id_48058 : Int = _range_id_48050::Step; + let _end_id_48063 : Int = _range_id_48050::End; + while _step_id_48058 > 0 and _index_id_48053 <= _end_id_48063 or _step_id_48058 < 0 and _index_id_48053 >= _end_id_48063 { + let _ : Int = _index_id_48053; u(target); - _index_id_48037 += _step_id_48042; + _index_id_48053 += _step_id_48058; } } @@ -130,14 +130,14 @@ fn analysis_apply_operation_power_ca_consumer() { { let _range : Range = 1..AbsI(power); { - let _range_id_48077 : Range = _range::Start + _range::End - _range::Start / _range::Step * _range::Step..-_range::Step.._range::Start; - mutable _index_id_48080 : Int = _range_id_48077::Start; - let _step_id_48085 : Int = _range_id_48077::Step; - let _end_id_48090 : Int = _range_id_48077::End; - while _step_id_48085 > 0 and _index_id_48080 <= _end_id_48090 or _step_id_48085 < 0 and _index_id_48080 >= _end_id_48090 { - let _ : Int = _index_id_48080; + let _range_id_48093 : Range = _range::Start + _range::End - _range::Start / _range::Step * _range::Step..-_range::Step.._range::Start; + mutable _index_id_48096 : Int = _range_id_48093::Start; + let _step_id_48101 : Int = _range_id_48093::Step; + let _end_id_48106 : Int = _range_id_48093::End; + while _step_id_48101 > 0 and _index_id_48096 <= _end_id_48106 or _step_id_48101 < 0 and _index_id_48096 >= _end_id_48106 { + let _ : Int = _index_id_48096; Adjoint u(target); - _index_id_48080 += _step_id_48085; + _index_id_48096 += _step_id_48101; } } @@ -152,14 +152,14 @@ fn analysis_apply_operation_power_ca_consumer() { Adjoint op }; { - let _range_id_48120 : Range = 1..AbsI(power); - mutable _index_id_48123 : Int = _range_id_48120::Start; - let _step_id_48128 : Int = _range_id_48120::Step; - let _end_id_48133 : Int = _range_id_48120::End; - while _step_id_48128 > 0 and _index_id_48123 <= _end_id_48133 or _step_id_48128 < 0 and _index_id_48123 >= _end_id_48133 { - let _ : Int = _index_id_48123; + let _range_id_48136 : Range = 1..AbsI(power); + mutable _index_id_48139 : Int = _range_id_48136::Start; + let _step_id_48144 : Int = _range_id_48136::Step; + let _end_id_48149 : Int = _range_id_48136::End; + while _step_id_48144 > 0 and _index_id_48139 <= _end_id_48149 or _step_id_48144 < 0 and _index_id_48139 >= _end_id_48149 { + let _ : Int = _index_id_48139; Controlled u(ctls, target); - _index_id_48123 += _step_id_48128; + _index_id_48139 += _step_id_48144; } } @@ -174,14 +174,14 @@ fn analysis_apply_operation_power_ca_consumer() { { let _range : Range = 1..AbsI(power); { - let _range_id_48163 : Range = _range::Start + _range::End - _range::Start / _range::Step * _range::Step..-_range::Step.._range::Start; - mutable _index_id_48166 : Int = _range_id_48163::Start; - let _step_id_48171 : Int = _range_id_48163::Step; - let _end_id_48176 : Int = _range_id_48163::End; - while _step_id_48171 > 0 and _index_id_48166 <= _end_id_48176 or _step_id_48171 < 0 and _index_id_48166 >= _end_id_48176 { - let _ : Int = _index_id_48166; + let _range_id_48179 : Range = _range::Start + _range::End - _range::Start / _range::Step * _range::Step..-_range::Step.._range::Start; + mutable _index_id_48182 : Int = _range_id_48179::Start; + let _step_id_48187 : Int = _range_id_48179::Step; + let _end_id_48192 : Int = _range_id_48179::End; + while _step_id_48187 > 0 and _index_id_48182 <= _end_id_48192 or _step_id_48187 < 0 and _index_id_48182 >= _end_id_48192 { + let _ : Int = _index_id_48182; Controlled Adjoint u(ctls, target); - _index_id_48166 += _step_id_48171; + _index_id_48182 += _step_id_48187; } } @@ -245,14 +245,14 @@ fn analysis_apply_operation_power_ca_consumer() { Adjoint op }; { - let _range_id_48034 : Range = 1..AbsI(power); - mutable _index_id_48037 : Int = _range_id_48034::Start; - let _step_id_48042 : Int = _range_id_48034::Step; - let _end_id_48047 : Int = _range_id_48034::End; - while _step_id_48042 > 0 and _index_id_48037 <= _end_id_48047 or _step_id_48042 < 0 and _index_id_48037 >= _end_id_48047 { - let _ : Int = _index_id_48037; + let _range_id_48050 : Range = 1..AbsI(power); + mutable _index_id_48053 : Int = _range_id_48050::Start; + let _step_id_48058 : Int = _range_id_48050::Step; + let _end_id_48063 : Int = _range_id_48050::End; + while _step_id_48058 > 0 and _index_id_48053 <= _end_id_48063 or _step_id_48058 < 0 and _index_id_48053 >= _end_id_48063 { + let _ : Int = _index_id_48053; u(target); - _index_id_48037 += _step_id_48042; + _index_id_48053 += _step_id_48058; } } @@ -267,14 +267,14 @@ fn analysis_apply_operation_power_ca_consumer() { { let _range : Range = 1..AbsI(power); { - let _range_id_48077 : Range = _range::Start + _range::End - _range::Start / _range::Step * _range::Step..-_range::Step.._range::Start; - mutable _index_id_48080 : Int = _range_id_48077::Start; - let _step_id_48085 : Int = _range_id_48077::Step; - let _end_id_48090 : Int = _range_id_48077::End; - while _step_id_48085 > 0 and _index_id_48080 <= _end_id_48090 or _step_id_48085 < 0 and _index_id_48080 >= _end_id_48090 { - let _ : Int = _index_id_48080; + let _range_id_48093 : Range = _range::Start + _range::End - _range::Start / _range::Step * _range::Step..-_range::Step.._range::Start; + mutable _index_id_48096 : Int = _range_id_48093::Start; + let _step_id_48101 : Int = _range_id_48093::Step; + let _end_id_48106 : Int = _range_id_48093::End; + while _step_id_48101 > 0 and _index_id_48096 <= _end_id_48106 or _step_id_48101 < 0 and _index_id_48096 >= _end_id_48106 { + let _ : Int = _index_id_48096; Adjoint u(target); - _index_id_48080 += _step_id_48085; + _index_id_48096 += _step_id_48101; } } @@ -289,14 +289,14 @@ fn analysis_apply_operation_power_ca_consumer() { Adjoint op }; { - let _range_id_48120 : Range = 1..AbsI(power); - mutable _index_id_48123 : Int = _range_id_48120::Start; - let _step_id_48128 : Int = _range_id_48120::Step; - let _end_id_48133 : Int = _range_id_48120::End; - while _step_id_48128 > 0 and _index_id_48123 <= _end_id_48133 or _step_id_48128 < 0 and _index_id_48123 >= _end_id_48133 { - let _ : Int = _index_id_48123; + let _range_id_48136 : Range = 1..AbsI(power); + mutable _index_id_48139 : Int = _range_id_48136::Start; + let _step_id_48144 : Int = _range_id_48136::Step; + let _end_id_48149 : Int = _range_id_48136::End; + while _step_id_48144 > 0 and _index_id_48139 <= _end_id_48149 or _step_id_48144 < 0 and _index_id_48139 >= _end_id_48149 { + let _ : Int = _index_id_48139; Controlled u(ctls, target); - _index_id_48123 += _step_id_48128; + _index_id_48139 += _step_id_48144; } } @@ -311,14 +311,14 @@ fn analysis_apply_operation_power_ca_consumer() { { let _range : Range = 1..AbsI(power); { - let _range_id_48163 : Range = _range::Start + _range::End - _range::Start / _range::Step * _range::Step..-_range::Step.._range::Start; - mutable _index_id_48166 : Int = _range_id_48163::Start; - let _step_id_48171 : Int = _range_id_48163::Step; - let _end_id_48176 : Int = _range_id_48163::End; - while _step_id_48171 > 0 and _index_id_48166 <= _end_id_48176 or _step_id_48171 < 0 and _index_id_48166 >= _end_id_48176 { - let _ : Int = _index_id_48166; + let _range_id_48179 : Range = _range::Start + _range::End - _range::Start / _range::Step * _range::Step..-_range::Step.._range::Start; + mutable _index_id_48182 : Int = _range_id_48179::Start; + let _step_id_48187 : Int = _range_id_48179::Step; + let _end_id_48192 : Int = _range_id_48179::End; + while _step_id_48187 > 0 and _index_id_48182 <= _end_id_48192 or _step_id_48187 < 0 and _index_id_48182 >= _end_id_48192 { + let _ : Int = _index_id_48182; Controlled Adjoint u(ctls, target); - _index_id_48166 += _step_id_48171; + _index_id_48182 += _step_id_48187; } } @@ -353,18 +353,18 @@ fn analysis_apply_operation_power_ca_consumer() { operation ApplyOperationPowerCA__Qubit_____AdjCtl__U_(power : Int, target : Qubit[]) : Unit is Adj + Ctl { body ... { { - let _range_id_48034 : Range = 1..AbsI(power); - mutable _index_id_48037 : Int = _range_id_48034::Start; - let _step_id_48042 : Int = _range_id_48034::Step; - let _end_id_48047 : Int = _range_id_48034::End; - while _step_id_48042 > 0 and _index_id_48037 <= _end_id_48047 or _step_id_48042 < 0 and _index_id_48037 >= _end_id_48047 { - let _ : Int = _index_id_48037; + let _range_id_48050 : Range = 1..AbsI(power); + mutable _index_id_48053 : Int = _range_id_48050::Start; + let _step_id_48058 : Int = _range_id_48050::Step; + let _end_id_48063 : Int = _range_id_48050::End; + while _step_id_48058 > 0 and _index_id_48053 <= _end_id_48063 or _step_id_48058 < 0 and _index_id_48053 >= _end_id_48063 { + let _ : Int = _index_id_48053; if power >= 0 { U(target) } else { Adjoint U(target) }; - _index_id_48037 += _step_id_48042; + _index_id_48053 += _step_id_48058; } } @@ -374,18 +374,18 @@ fn analysis_apply_operation_power_ca_consumer() { { let _range : Range = 1..AbsI(power); { - let _range_id_48077 : Range = _range::Start + _range::End - _range::Start / _range::Step * _range::Step..-_range::Step.._range::Start; - mutable _index_id_48080 : Int = _range_id_48077::Start; - let _step_id_48085 : Int = _range_id_48077::Step; - let _end_id_48090 : Int = _range_id_48077::End; - while _step_id_48085 > 0 and _index_id_48080 <= _end_id_48090 or _step_id_48085 < 0 and _index_id_48080 >= _end_id_48090 { - let _ : Int = _index_id_48080; + let _range_id_48093 : Range = _range::Start + _range::End - _range::Start / _range::Step * _range::Step..-_range::Step.._range::Start; + mutable _index_id_48096 : Int = _range_id_48093::Start; + let _step_id_48101 : Int = _range_id_48093::Step; + let _end_id_48106 : Int = _range_id_48093::End; + while _step_id_48101 > 0 and _index_id_48096 <= _end_id_48106 or _step_id_48101 < 0 and _index_id_48096 >= _end_id_48106 { + let _ : Int = _index_id_48096; if power >= 0 { Adjoint U(target) } else { U(target) }; - _index_id_48080 += _step_id_48085; + _index_id_48096 += _step_id_48101; } } @@ -395,18 +395,18 @@ fn analysis_apply_operation_power_ca_consumer() { } controlled (ctls, ...) { { - let _range_id_48120 : Range = 1..AbsI(power); - mutable _index_id_48123 : Int = _range_id_48120::Start; - let _step_id_48128 : Int = _range_id_48120::Step; - let _end_id_48133 : Int = _range_id_48120::End; - while _step_id_48128 > 0 and _index_id_48123 <= _end_id_48133 or _step_id_48128 < 0 and _index_id_48123 >= _end_id_48133 { - let _ : Int = _index_id_48123; + let _range_id_48136 : Range = 1..AbsI(power); + mutable _index_id_48139 : Int = _range_id_48136::Start; + let _step_id_48144 : Int = _range_id_48136::Step; + let _end_id_48149 : Int = _range_id_48136::End; + while _step_id_48144 > 0 and _index_id_48139 <= _end_id_48149 or _step_id_48144 < 0 and _index_id_48139 >= _end_id_48149 { + let _ : Int = _index_id_48139; if power >= 0 { Controlled U(ctls, target) } else { Controlled Adjoint U(ctls, target) }; - _index_id_48123 += _step_id_48128; + _index_id_48139 += _step_id_48144; } } @@ -416,18 +416,18 @@ fn analysis_apply_operation_power_ca_consumer() { { let _range : Range = 1..AbsI(power); { - let _range_id_48163 : Range = _range::Start + _range::End - _range::Start / _range::Step * _range::Step..-_range::Step.._range::Start; - mutable _index_id_48166 : Int = _range_id_48163::Start; - let _step_id_48171 : Int = _range_id_48163::Step; - let _end_id_48176 : Int = _range_id_48163::End; - while _step_id_48171 > 0 and _index_id_48166 <= _end_id_48176 or _step_id_48171 < 0 and _index_id_48166 >= _end_id_48176 { - let _ : Int = _index_id_48166; + let _range_id_48179 : Range = _range::Start + _range::End - _range::Start / _range::Step * _range::Step..-_range::Step.._range::Start; + mutable _index_id_48182 : Int = _range_id_48179::Start; + let _step_id_48187 : Int = _range_id_48179::Step; + let _end_id_48192 : Int = _range_id_48179::End; + while _step_id_48187 > 0 and _index_id_48182 <= _end_id_48192 or _step_id_48187 < 0 and _index_id_48182 >= _end_id_48192 { + let _ : Int = _index_id_48182; if power >= 0 { Controlled Adjoint U(ctls, target) } else { Controlled U(ctls, target) }; - _index_id_48166 += _step_id_48171; + _index_id_48182 += _step_id_48187; } } @@ -588,13 +588,13 @@ fn analysis_bernstein_vazirani_sample_shape() { operation ApplyToEachA_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit is Adj { body ... { { - let _array_id_46251 : Qubit[] = register; - let _len_id_46255 : Int = Length(_array_id_46251); - mutable _index_id_46260 : Int = 0; - while _index_id_46260 < _len_id_46255 { - let item : Qubit = _array_id_46251[_index_id_46260]; + let _array_id_46267 : Qubit[] = register; + let _len_id_46271 : Int = Length(_array_id_46267); + mutable _index_id_46276 : Int = 0; + while _index_id_46276 < _len_id_46271 { + let item : Qubit = _array_id_46267[_index_id_46276]; singleElementOperation(item); - _index_id_46260 += 1; + _index_id_46276 += 1; } } @@ -604,15 +604,15 @@ fn analysis_bernstein_vazirani_sample_shape() { { let _array : Qubit[] = register; { - let _range_id_46279 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46282 : Int = _range_id_46279::Start; - let _step_id_46287 : Int = _range_id_46279::Step; - let _end_id_46292 : Int = _range_id_46279::End; - while _step_id_46287 > 0 and _index_id_46282 <= _end_id_46292 or _step_id_46287 < 0 and _index_id_46282 >= _end_id_46292 { - let _index : Int = _index_id_46282; + let _range_id_46295 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46298 : Int = _range_id_46295::Start; + let _step_id_46303 : Int = _range_id_46295::Step; + let _end_id_46308 : Int = _range_id_46295::End; + while _step_id_46303 > 0 and _index_id_46298 <= _end_id_46308 or _step_id_46303 < 0 and _index_id_46298 >= _end_id_46308 { + let _index : Int = _index_id_46298; let item : Qubit = _array[_index]; Adjoint singleElementOperation(item); - _index_id_46282 += _step_id_46287; + _index_id_46298 += _step_id_46303; } } @@ -738,13 +738,13 @@ fn analysis_bernstein_vazirani_sample_shape() { operation ApplyToEachA_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit is Adj { body ... { { - let _array_id_46251 : Qubit[] = register; - let _len_id_46255 : Int = Length(_array_id_46251); - mutable _index_id_46260 : Int = 0; - while _index_id_46260 < _len_id_46255 { - let item : Qubit = _array_id_46251[_index_id_46260]; + let _array_id_46267 : Qubit[] = register; + let _len_id_46271 : Int = Length(_array_id_46267); + mutable _index_id_46276 : Int = 0; + while _index_id_46276 < _len_id_46271 { + let item : Qubit = _array_id_46267[_index_id_46276]; singleElementOperation(item); - _index_id_46260 += 1; + _index_id_46276 += 1; } } @@ -754,15 +754,15 @@ fn analysis_bernstein_vazirani_sample_shape() { { let _array : Qubit[] = register; { - let _range_id_46279 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46282 : Int = _range_id_46279::Start; - let _step_id_46287 : Int = _range_id_46279::Step; - let _end_id_46292 : Int = _range_id_46279::End; - while _step_id_46287 > 0 and _index_id_46282 <= _end_id_46292 or _step_id_46287 < 0 and _index_id_46282 >= _end_id_46292 { - let _index : Int = _index_id_46282; + let _range_id_46295 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46298 : Int = _range_id_46295::Start; + let _step_id_46303 : Int = _range_id_46295::Step; + let _end_id_46308 : Int = _range_id_46295::End; + while _step_id_46303 > 0 and _index_id_46298 <= _end_id_46308 or _step_id_46303 < 0 and _index_id_46298 >= _end_id_46308 { + let _index : Int = _index_id_46298; let item : Qubit = _array[_index]; Adjoint singleElementOperation(item); - _index_id_46282 += _step_id_46287; + _index_id_46298 += _step_id_46303; } } @@ -810,13 +810,13 @@ fn analysis_bernstein_vazirani_sample_shape() { operation ApplyToEachA_Qubit__AdjCtl__H_(register : Qubit[]) : Unit is Adj { body ... { { - let _array_id_46251 : Qubit[] = register; - let _len_id_46255 : Int = Length(_array_id_46251); - mutable _index_id_46260 : Int = 0; - while _index_id_46260 < _len_id_46255 { - let item : Qubit = _array_id_46251[_index_id_46260]; + let _array_id_46267 : Qubit[] = register; + let _len_id_46271 : Int = Length(_array_id_46267); + mutable _index_id_46276 : Int = 0; + while _index_id_46276 < _len_id_46271 { + let item : Qubit = _array_id_46267[_index_id_46276]; H(item); - _index_id_46260 += 1; + _index_id_46276 += 1; } } @@ -826,15 +826,15 @@ fn analysis_bernstein_vazirani_sample_shape() { { let _array : Qubit[] = register; { - let _range_id_46279 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46282 : Int = _range_id_46279::Start; - let _step_id_46287 : Int = _range_id_46279::Step; - let _end_id_46292 : Int = _range_id_46279::End; - while _step_id_46287 > 0 and _index_id_46282 <= _end_id_46292 or _step_id_46287 < 0 and _index_id_46282 >= _end_id_46292 { - let _index : Int = _index_id_46282; + let _range_id_46295 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46298 : Int = _range_id_46295::Start; + let _step_id_46303 : Int = _range_id_46295::Step; + let _end_id_46308 : Int = _range_id_46295::End; + while _step_id_46303 > 0 and _index_id_46298 <= _end_id_46308 or _step_id_46303 < 0 and _index_id_46298 >= _end_id_46308 { + let _index : Int = _index_id_46298; let item : Qubit = _array[_index]; Adjoint H(item); - _index_id_46282 += _step_id_46287; + _index_id_46298 += _step_id_46303; } } @@ -873,13 +873,13 @@ fn analysis_bernstein_vazirani_sample_shape() { operation ApplyToEachA_Qubit__AdjCtl__H_(register : Qubit[]) : Unit is Adj { body ... { { - let _array_id_46251 : Qubit[] = register; - let _len_id_46255 : Int = Length(_array_id_46251); - mutable _index_id_46260 : Int = 0; - while _index_id_46260 < _len_id_46255 { - let item : Qubit = _array_id_46251[_index_id_46260]; + let _array_id_46267 : Qubit[] = register; + let _len_id_46271 : Int = Length(_array_id_46267); + mutable _index_id_46276 : Int = 0; + while _index_id_46276 < _len_id_46271 { + let item : Qubit = _array_id_46267[_index_id_46276]; H(item); - _index_id_46260 += 1; + _index_id_46276 += 1; } } @@ -889,15 +889,15 @@ fn analysis_bernstein_vazirani_sample_shape() { { let _array : Qubit[] = register; { - let _range_id_46279 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46282 : Int = _range_id_46279::Start; - let _step_id_46287 : Int = _range_id_46279::Step; - let _end_id_46292 : Int = _range_id_46279::End; - while _step_id_46287 > 0 and _index_id_46282 <= _end_id_46292 or _step_id_46287 < 0 and _index_id_46282 >= _end_id_46292 { - let _index : Int = _index_id_46282; + let _range_id_46295 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46298 : Int = _range_id_46295::Start; + let _step_id_46303 : Int = _range_id_46295::Step; + let _end_id_46308 : Int = _range_id_46295::End; + while _step_id_46303 > 0 and _index_id_46298 <= _end_id_46308 or _step_id_46303 < 0 and _index_id_46298 >= _end_id_46308 { + let _index : Int = _index_id_46298; let item : Qubit = _array[_index]; Adjoint H(item); - _index_id_46282 += _step_id_46287; + _index_id_46298 += _step_id_46303; } } @@ -1925,13 +1925,13 @@ fn full_pipeline_handles_stdlib_apply_to_each() { } operation ApplyToEach_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit { { - let _array_id_46213 : Qubit[] = register; - let _len_id_46217 : Int = Length(_array_id_46213); - mutable _index_id_46222 : Int = 0; - while _index_id_46222 < _len_id_46217 { - let item : Qubit = _array_id_46213[_index_id_46222]; + let _array_id_46229 : Qubit[] = register; + let _len_id_46233 : Int = Length(_array_id_46229); + mutable _index_id_46238 : Int = 0; + while _index_id_46238 < _len_id_46233 { + let item : Qubit = _array_id_46229[_index_id_46238]; singleElementOperation(item); - _index_id_46222 += 1; + _index_id_46238 += 1; } } @@ -1952,13 +1952,13 @@ fn full_pipeline_handles_stdlib_apply_to_each() { } operation ApplyToEach_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit { { - let _array_id_46213 : Qubit[] = register; - let _len_id_46217 : Int = Length(_array_id_46213); - mutable _index_id_46222 : Int = 0; - while _index_id_46222 < _len_id_46217 { - let item : Qubit = _array_id_46213[_index_id_46222]; + let _array_id_46229 : Qubit[] = register; + let _len_id_46233 : Int = Length(_array_id_46229); + mutable _index_id_46238 : Int = 0; + while _index_id_46238 < _len_id_46233 { + let item : Qubit = _array_id_46229[_index_id_46238]; singleElementOperation(item); - _index_id_46222 += 1; + _index_id_46238 += 1; } } @@ -1966,13 +1966,13 @@ fn full_pipeline_handles_stdlib_apply_to_each() { } operation ApplyToEach_Qubit__AdjCtl__H_(register : Qubit[]) : Unit { { - let _array_id_46213 : Qubit[] = register; - let _len_id_46217 : Int = Length(_array_id_46213); - mutable _index_id_46222 : Int = 0; - while _index_id_46222 < _len_id_46217 { - let item : Qubit = _array_id_46213[_index_id_46222]; + let _array_id_46229 : Qubit[] = register; + let _len_id_46233 : Int = Length(_array_id_46229); + mutable _index_id_46238 : Int = 0; + while _index_id_46238 < _len_id_46233 { + let item : Qubit = _array_id_46229[_index_id_46238]; H(item); - _index_id_46222 += 1; + _index_id_46238 += 1; } } @@ -2009,13 +2009,13 @@ fn full_pipeline_handles_stdlib_apply_to_each_with_custom_intrinsic() { } operation ApplyToEach_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit { { - let _array_id_46213 : Qubit[] = register; - let _len_id_46217 : Int = Length(_array_id_46213); - mutable _index_id_46222 : Int = 0; - while _index_id_46222 < _len_id_46217 { - let item : Qubit = _array_id_46213[_index_id_46222]; + let _array_id_46229 : Qubit[] = register; + let _len_id_46233 : Int = Length(_array_id_46229); + mutable _index_id_46238 : Int = 0; + while _index_id_46238 < _len_id_46233 { + let item : Qubit = _array_id_46229[_index_id_46238]; singleElementOperation(item); - _index_id_46222 += 1; + _index_id_46238 += 1; } } @@ -2036,13 +2036,13 @@ fn full_pipeline_handles_stdlib_apply_to_each_with_custom_intrinsic() { } operation ApplyToEach_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit { { - let _array_id_46213 : Qubit[] = register; - let _len_id_46217 : Int = Length(_array_id_46213); - mutable _index_id_46222 : Int = 0; - while _index_id_46222 < _len_id_46217 { - let item : Qubit = _array_id_46213[_index_id_46222]; + let _array_id_46229 : Qubit[] = register; + let _len_id_46233 : Int = Length(_array_id_46229); + mutable _index_id_46238 : Int = 0; + while _index_id_46238 < _len_id_46233 { + let item : Qubit = _array_id_46229[_index_id_46238]; singleElementOperation(item); - _index_id_46222 += 1; + _index_id_46238 += 1; } } @@ -2050,13 +2050,13 @@ fn full_pipeline_handles_stdlib_apply_to_each_with_custom_intrinsic() { } operation ApplyToEach_Qubit__AdjCtl__SX_(register : Qubit[]) : Unit { { - let _array_id_46213 : Qubit[] = register; - let _len_id_46217 : Int = Length(_array_id_46213); - mutable _index_id_46222 : Int = 0; - while _index_id_46222 < _len_id_46217 { - let item : Qubit = _array_id_46213[_index_id_46222]; + let _array_id_46229 : Qubit[] = register; + let _len_id_46233 : Int = Length(_array_id_46229); + mutable _index_id_46238 : Int = 0; + while _index_id_46238 < _len_id_46233 { + let item : Qubit = _array_id_46229[_index_id_46238]; SX(item); - _index_id_46222 += 1; + _index_id_46238 += 1; } } @@ -2093,13 +2093,13 @@ fn apply_to_each_body_callable_defunctionalizes() { } operation ApplyToEach_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit { { - let _array_id_46213 : Qubit[] = register; - let _len_id_46217 : Int = Length(_array_id_46213); - mutable _index_id_46222 : Int = 0; - while _index_id_46222 < _len_id_46217 { - let item : Qubit = _array_id_46213[_index_id_46222]; + let _array_id_46229 : Qubit[] = register; + let _len_id_46233 : Int = Length(_array_id_46229); + mutable _index_id_46238 : Int = 0; + while _index_id_46238 < _len_id_46233 { + let item : Qubit = _array_id_46229[_index_id_46238]; singleElementOperation(item); - _index_id_46222 += 1; + _index_id_46238 += 1; } } @@ -2120,13 +2120,13 @@ fn apply_to_each_body_callable_defunctionalizes() { } operation ApplyToEach_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit { { - let _array_id_46213 : Qubit[] = register; - let _len_id_46217 : Int = Length(_array_id_46213); - mutable _index_id_46222 : Int = 0; - while _index_id_46222 < _len_id_46217 { - let item : Qubit = _array_id_46213[_index_id_46222]; + let _array_id_46229 : Qubit[] = register; + let _len_id_46233 : Int = Length(_array_id_46229); + mutable _index_id_46238 : Int = 0; + while _index_id_46238 < _len_id_46233 { + let item : Qubit = _array_id_46229[_index_id_46238]; singleElementOperation(item); - _index_id_46222 += 1; + _index_id_46238 += 1; } } @@ -2134,13 +2134,13 @@ fn apply_to_each_body_callable_defunctionalizes() { } operation ApplyToEach_Qubit__AdjCtl__H_(register : Qubit[]) : Unit { { - let _array_id_46213 : Qubit[] = register; - let _len_id_46217 : Int = Length(_array_id_46213); - mutable _index_id_46222 : Int = 0; - while _index_id_46222 < _len_id_46217 { - let item : Qubit = _array_id_46213[_index_id_46222]; + let _array_id_46229 : Qubit[] = register; + let _len_id_46233 : Int = Length(_array_id_46229); + mutable _index_id_46238 : Int = 0; + while _index_id_46238 < _len_id_46233 { + let item : Qubit = _array_id_46229[_index_id_46238]; H(item); - _index_id_46222 += 1; + _index_id_46238 += 1; } } @@ -2180,13 +2180,13 @@ fn apply_to_each_a_adjoint_callable_defunctionalizes() { operation ApplyToEachA_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit is Adj { body ... { { - let _array_id_46241 : Qubit[] = register; - let _len_id_46245 : Int = Length(_array_id_46241); - mutable _index_id_46250 : Int = 0; - while _index_id_46250 < _len_id_46245 { - let item : Qubit = _array_id_46241[_index_id_46250]; + let _array_id_46257 : Qubit[] = register; + let _len_id_46261 : Int = Length(_array_id_46257); + mutable _index_id_46266 : Int = 0; + while _index_id_46266 < _len_id_46261 { + let item : Qubit = _array_id_46257[_index_id_46266]; singleElementOperation(item); - _index_id_46250 += 1; + _index_id_46266 += 1; } } @@ -2196,15 +2196,15 @@ fn apply_to_each_a_adjoint_callable_defunctionalizes() { { let _array : Qubit[] = register; { - let _range_id_46269 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46272 : Int = _range_id_46269::Start; - let _step_id_46277 : Int = _range_id_46269::Step; - let _end_id_46282 : Int = _range_id_46269::End; - while _step_id_46277 > 0 and _index_id_46272 <= _end_id_46282 or _step_id_46277 < 0 and _index_id_46272 >= _end_id_46282 { - let _index : Int = _index_id_46272; + let _range_id_46285 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46288 : Int = _range_id_46285::Start; + let _step_id_46293 : Int = _range_id_46285::Step; + let _end_id_46298 : Int = _range_id_46285::End; + while _step_id_46293 > 0 and _index_id_46288 <= _end_id_46298 or _step_id_46293 < 0 and _index_id_46288 >= _end_id_46298 { + let _index : Int = _index_id_46288; let item : Qubit = _array[_index]; Adjoint singleElementOperation(item); - _index_id_46272 += _step_id_46277; + _index_id_46288 += _step_id_46293; } } @@ -2230,13 +2230,13 @@ fn apply_to_each_a_adjoint_callable_defunctionalizes() { operation ApplyToEachA_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit is Adj { body ... { { - let _array_id_46241 : Qubit[] = register; - let _len_id_46245 : Int = Length(_array_id_46241); - mutable _index_id_46250 : Int = 0; - while _index_id_46250 < _len_id_46245 { - let item : Qubit = _array_id_46241[_index_id_46250]; + let _array_id_46257 : Qubit[] = register; + let _len_id_46261 : Int = Length(_array_id_46257); + mutable _index_id_46266 : Int = 0; + while _index_id_46266 < _len_id_46261 { + let item : Qubit = _array_id_46257[_index_id_46266]; singleElementOperation(item); - _index_id_46250 += 1; + _index_id_46266 += 1; } } @@ -2246,15 +2246,15 @@ fn apply_to_each_a_adjoint_callable_defunctionalizes() { { let _array : Qubit[] = register; { - let _range_id_46269 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46272 : Int = _range_id_46269::Start; - let _step_id_46277 : Int = _range_id_46269::Step; - let _end_id_46282 : Int = _range_id_46269::End; - while _step_id_46277 > 0 and _index_id_46272 <= _end_id_46282 or _step_id_46277 < 0 and _index_id_46272 >= _end_id_46282 { - let _index : Int = _index_id_46272; + let _range_id_46285 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46288 : Int = _range_id_46285::Start; + let _step_id_46293 : Int = _range_id_46285::Step; + let _end_id_46298 : Int = _range_id_46285::End; + while _step_id_46293 > 0 and _index_id_46288 <= _end_id_46298 or _step_id_46293 < 0 and _index_id_46288 >= _end_id_46298 { + let _index : Int = _index_id_46288; let item : Qubit = _array[_index]; Adjoint singleElementOperation(item); - _index_id_46272 += _step_id_46277; + _index_id_46288 += _step_id_46293; } } @@ -2266,13 +2266,13 @@ fn apply_to_each_a_adjoint_callable_defunctionalizes() { operation ApplyToEachA_Qubit__AdjCtl__S_(register : Qubit[]) : Unit is Adj { body ... { { - let _array_id_46241 : Qubit[] = register; - let _len_id_46245 : Int = Length(_array_id_46241); - mutable _index_id_46250 : Int = 0; - while _index_id_46250 < _len_id_46245 { - let item : Qubit = _array_id_46241[_index_id_46250]; + let _array_id_46257 : Qubit[] = register; + let _len_id_46261 : Int = Length(_array_id_46257); + mutable _index_id_46266 : Int = 0; + while _index_id_46266 < _len_id_46261 { + let item : Qubit = _array_id_46257[_index_id_46266]; S(item); - _index_id_46250 += 1; + _index_id_46266 += 1; } } @@ -2282,15 +2282,15 @@ fn apply_to_each_a_adjoint_callable_defunctionalizes() { { let _array : Qubit[] = register; { - let _range_id_46269 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46272 : Int = _range_id_46269::Start; - let _step_id_46277 : Int = _range_id_46269::Step; - let _end_id_46282 : Int = _range_id_46269::End; - while _step_id_46277 > 0 and _index_id_46272 <= _end_id_46282 or _step_id_46277 < 0 and _index_id_46272 >= _end_id_46282 { - let _index : Int = _index_id_46272; + let _range_id_46285 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46288 : Int = _range_id_46285::Start; + let _step_id_46293 : Int = _range_id_46285::Step; + let _end_id_46298 : Int = _range_id_46285::End; + while _step_id_46293 > 0 and _index_id_46288 <= _end_id_46298 or _step_id_46293 < 0 and _index_id_46288 >= _end_id_46298 { + let _index : Int = _index_id_46288; let item : Qubit = _array[_index]; Adjoint S(item); - _index_id_46272 += _step_id_46277; + _index_id_46288 += _step_id_46293; } } @@ -2334,13 +2334,13 @@ fn apply_to_each_c_controlled_callable_defunctionalizes() { operation ApplyToEachC_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit is Ctl { body ... { { - let _array_id_46312 : Qubit[] = register; - let _len_id_46316 : Int = Length(_array_id_46312); - mutable _index_id_46321 : Int = 0; - while _index_id_46321 < _len_id_46316 { - let item : Qubit = _array_id_46312[_index_id_46321]; + let _array_id_46328 : Qubit[] = register; + let _len_id_46332 : Int = Length(_array_id_46328); + mutable _index_id_46337 : Int = 0; + while _index_id_46337 < _len_id_46332 { + let item : Qubit = _array_id_46328[_index_id_46337]; singleElementOperation(item); - _index_id_46321 += 1; + _index_id_46337 += 1; } } @@ -2348,13 +2348,13 @@ fn apply_to_each_c_controlled_callable_defunctionalizes() { } controlled (ctls, ...) { { - let _array_id_46340 : Qubit[] = register; - let _len_id_46344 : Int = Length(_array_id_46340); - mutable _index_id_46349 : Int = 0; - while _index_id_46349 < _len_id_46344 { - let item : Qubit = _array_id_46340[_index_id_46349]; + let _array_id_46356 : Qubit[] = register; + let _len_id_46360 : Int = Length(_array_id_46356); + mutable _index_id_46365 : Int = 0; + while _index_id_46365 < _len_id_46360 { + let item : Qubit = _array_id_46356[_index_id_46365]; Controlled singleElementOperation(ctls, item); - _index_id_46349 += 1; + _index_id_46365 += 1; } } @@ -2380,13 +2380,13 @@ fn apply_to_each_c_controlled_callable_defunctionalizes() { operation ApplyToEachC_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit is Ctl { body ... { { - let _array_id_46312 : Qubit[] = register; - let _len_id_46316 : Int = Length(_array_id_46312); - mutable _index_id_46321 : Int = 0; - while _index_id_46321 < _len_id_46316 { - let item : Qubit = _array_id_46312[_index_id_46321]; + let _array_id_46328 : Qubit[] = register; + let _len_id_46332 : Int = Length(_array_id_46328); + mutable _index_id_46337 : Int = 0; + while _index_id_46337 < _len_id_46332 { + let item : Qubit = _array_id_46328[_index_id_46337]; singleElementOperation(item); - _index_id_46321 += 1; + _index_id_46337 += 1; } } @@ -2394,13 +2394,13 @@ fn apply_to_each_c_controlled_callable_defunctionalizes() { } controlled (ctls, ...) { { - let _array_id_46340 : Qubit[] = register; - let _len_id_46344 : Int = Length(_array_id_46340); - mutable _index_id_46349 : Int = 0; - while _index_id_46349 < _len_id_46344 { - let item : Qubit = _array_id_46340[_index_id_46349]; + let _array_id_46356 : Qubit[] = register; + let _len_id_46360 : Int = Length(_array_id_46356); + mutable _index_id_46365 : Int = 0; + while _index_id_46365 < _len_id_46360 { + let item : Qubit = _array_id_46356[_index_id_46365]; Controlled singleElementOperation(ctls, item); - _index_id_46349 += 1; + _index_id_46365 += 1; } } @@ -2410,13 +2410,13 @@ fn apply_to_each_c_controlled_callable_defunctionalizes() { operation ApplyToEachC_Qubit__AdjCtl__X_(register : Qubit[]) : Unit is Ctl { body ... { { - let _array_id_46312 : Qubit[] = register; - let _len_id_46316 : Int = Length(_array_id_46312); - mutable _index_id_46321 : Int = 0; - while _index_id_46321 < _len_id_46316 { - let item : Qubit = _array_id_46312[_index_id_46321]; + let _array_id_46328 : Qubit[] = register; + let _len_id_46332 : Int = Length(_array_id_46328); + mutable _index_id_46337 : Int = 0; + while _index_id_46337 < _len_id_46332 { + let item : Qubit = _array_id_46328[_index_id_46337]; X(item); - _index_id_46321 += 1; + _index_id_46337 += 1; } } @@ -2424,13 +2424,13 @@ fn apply_to_each_c_controlled_callable_defunctionalizes() { } controlled (ctls, ...) { { - let _array_id_46340 : Qubit[] = register; - let _len_id_46344 : Int = Length(_array_id_46340); - mutable _index_id_46349 : Int = 0; - while _index_id_46349 < _len_id_46344 { - let item : Qubit = _array_id_46340[_index_id_46349]; + let _array_id_46356 : Qubit[] = register; + let _len_id_46360 : Int = Length(_array_id_46356); + mutable _index_id_46365 : Int = 0; + while _index_id_46365 < _len_id_46360 { + let item : Qubit = _array_id_46356[_index_id_46365]; Controlled X(ctls, item); - _index_id_46349 += 1; + _index_id_46365 += 1; } } @@ -2469,13 +2469,13 @@ fn apply_to_each_ca_callable_defunctionalizes() { operation ApplyToEachCA_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit is Adj + Ctl { body ... { { - let _array_id_46368 : Qubit[] = register; - let _len_id_46372 : Int = Length(_array_id_46368); - mutable _index_id_46377 : Int = 0; - while _index_id_46377 < _len_id_46372 { - let item : Qubit = _array_id_46368[_index_id_46377]; + let _array_id_46384 : Qubit[] = register; + let _len_id_46388 : Int = Length(_array_id_46384); + mutable _index_id_46393 : Int = 0; + while _index_id_46393 < _len_id_46388 { + let item : Qubit = _array_id_46384[_index_id_46393]; singleElementOperation(item); - _index_id_46377 += 1; + _index_id_46393 += 1; } } @@ -2485,15 +2485,15 @@ fn apply_to_each_ca_callable_defunctionalizes() { { let _array : Qubit[] = register; { - let _range_id_46396 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46399 : Int = _range_id_46396::Start; - let _step_id_46404 : Int = _range_id_46396::Step; - let _end_id_46409 : Int = _range_id_46396::End; - while _step_id_46404 > 0 and _index_id_46399 <= _end_id_46409 or _step_id_46404 < 0 and _index_id_46399 >= _end_id_46409 { - let _index : Int = _index_id_46399; + let _range_id_46412 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46415 : Int = _range_id_46412::Start; + let _step_id_46420 : Int = _range_id_46412::Step; + let _end_id_46425 : Int = _range_id_46412::End; + while _step_id_46420 > 0 and _index_id_46415 <= _end_id_46425 or _step_id_46420 < 0 and _index_id_46415 >= _end_id_46425 { + let _index : Int = _index_id_46415; let item : Qubit = _array[_index]; Adjoint singleElementOperation(item); - _index_id_46399 += _step_id_46404; + _index_id_46415 += _step_id_46420; } } @@ -2503,13 +2503,13 @@ fn apply_to_each_ca_callable_defunctionalizes() { } controlled (ctls, ...) { { - let _array_id_46439 : Qubit[] = register; - let _len_id_46443 : Int = Length(_array_id_46439); - mutable _index_id_46448 : Int = 0; - while _index_id_46448 < _len_id_46443 { - let item : Qubit = _array_id_46439[_index_id_46448]; + let _array_id_46455 : Qubit[] = register; + let _len_id_46459 : Int = Length(_array_id_46455); + mutable _index_id_46464 : Int = 0; + while _index_id_46464 < _len_id_46459 { + let item : Qubit = _array_id_46455[_index_id_46464]; Controlled singleElementOperation(ctls, item); - _index_id_46448 += 1; + _index_id_46464 += 1; } } @@ -2519,15 +2519,15 @@ fn apply_to_each_ca_callable_defunctionalizes() { { let _array : Qubit[] = register; { - let _range_id_46467 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46470 : Int = _range_id_46467::Start; - let _step_id_46475 : Int = _range_id_46467::Step; - let _end_id_46480 : Int = _range_id_46467::End; - while _step_id_46475 > 0 and _index_id_46470 <= _end_id_46480 or _step_id_46475 < 0 and _index_id_46470 >= _end_id_46480 { - let _index : Int = _index_id_46470; + let _range_id_46483 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46486 : Int = _range_id_46483::Start; + let _step_id_46491 : Int = _range_id_46483::Step; + let _end_id_46496 : Int = _range_id_46483::End; + while _step_id_46491 > 0 and _index_id_46486 <= _end_id_46496 or _step_id_46491 < 0 and _index_id_46486 >= _end_id_46496 { + let _index : Int = _index_id_46486; let item : Qubit = _array[_index]; Controlled Adjoint singleElementOperation(ctls, item); - _index_id_46470 += _step_id_46475; + _index_id_46486 += _step_id_46491; } } @@ -2552,13 +2552,13 @@ fn apply_to_each_ca_callable_defunctionalizes() { operation ApplyToEachCA_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit is Adj + Ctl { body ... { { - let _array_id_46368 : Qubit[] = register; - let _len_id_46372 : Int = Length(_array_id_46368); - mutable _index_id_46377 : Int = 0; - while _index_id_46377 < _len_id_46372 { - let item : Qubit = _array_id_46368[_index_id_46377]; + let _array_id_46384 : Qubit[] = register; + let _len_id_46388 : Int = Length(_array_id_46384); + mutable _index_id_46393 : Int = 0; + while _index_id_46393 < _len_id_46388 { + let item : Qubit = _array_id_46384[_index_id_46393]; singleElementOperation(item); - _index_id_46377 += 1; + _index_id_46393 += 1; } } @@ -2568,15 +2568,15 @@ fn apply_to_each_ca_callable_defunctionalizes() { { let _array : Qubit[] = register; { - let _range_id_46396 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46399 : Int = _range_id_46396::Start; - let _step_id_46404 : Int = _range_id_46396::Step; - let _end_id_46409 : Int = _range_id_46396::End; - while _step_id_46404 > 0 and _index_id_46399 <= _end_id_46409 or _step_id_46404 < 0 and _index_id_46399 >= _end_id_46409 { - let _index : Int = _index_id_46399; + let _range_id_46412 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46415 : Int = _range_id_46412::Start; + let _step_id_46420 : Int = _range_id_46412::Step; + let _end_id_46425 : Int = _range_id_46412::End; + while _step_id_46420 > 0 and _index_id_46415 <= _end_id_46425 or _step_id_46420 < 0 and _index_id_46415 >= _end_id_46425 { + let _index : Int = _index_id_46415; let item : Qubit = _array[_index]; Adjoint singleElementOperation(item); - _index_id_46399 += _step_id_46404; + _index_id_46415 += _step_id_46420; } } @@ -2586,13 +2586,13 @@ fn apply_to_each_ca_callable_defunctionalizes() { } controlled (ctls, ...) { { - let _array_id_46439 : Qubit[] = register; - let _len_id_46443 : Int = Length(_array_id_46439); - mutable _index_id_46448 : Int = 0; - while _index_id_46448 < _len_id_46443 { - let item : Qubit = _array_id_46439[_index_id_46448]; + let _array_id_46455 : Qubit[] = register; + let _len_id_46459 : Int = Length(_array_id_46455); + mutable _index_id_46464 : Int = 0; + while _index_id_46464 < _len_id_46459 { + let item : Qubit = _array_id_46455[_index_id_46464]; Controlled singleElementOperation(ctls, item); - _index_id_46448 += 1; + _index_id_46464 += 1; } } @@ -2602,15 +2602,15 @@ fn apply_to_each_ca_callable_defunctionalizes() { { let _array : Qubit[] = register; { - let _range_id_46467 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46470 : Int = _range_id_46467::Start; - let _step_id_46475 : Int = _range_id_46467::Step; - let _end_id_46480 : Int = _range_id_46467::End; - while _step_id_46475 > 0 and _index_id_46470 <= _end_id_46480 or _step_id_46475 < 0 and _index_id_46470 >= _end_id_46480 { - let _index : Int = _index_id_46470; + let _range_id_46483 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46486 : Int = _range_id_46483::Start; + let _step_id_46491 : Int = _range_id_46483::Step; + let _end_id_46496 : Int = _range_id_46483::End; + while _step_id_46491 > 0 and _index_id_46486 <= _end_id_46496 or _step_id_46491 < 0 and _index_id_46486 >= _end_id_46496 { + let _index : Int = _index_id_46486; let item : Qubit = _array[_index]; Controlled Adjoint singleElementOperation(ctls, item); - _index_id_46470 += _step_id_46475; + _index_id_46486 += _step_id_46491; } } @@ -2622,13 +2622,13 @@ fn apply_to_each_ca_callable_defunctionalizes() { operation ApplyToEachCA_Qubit__AdjCtl__S_(register : Qubit[]) : Unit is Adj + Ctl { body ... { { - let _array_id_46368 : Qubit[] = register; - let _len_id_46372 : Int = Length(_array_id_46368); - mutable _index_id_46377 : Int = 0; - while _index_id_46377 < _len_id_46372 { - let item : Qubit = _array_id_46368[_index_id_46377]; + let _array_id_46384 : Qubit[] = register; + let _len_id_46388 : Int = Length(_array_id_46384); + mutable _index_id_46393 : Int = 0; + while _index_id_46393 < _len_id_46388 { + let item : Qubit = _array_id_46384[_index_id_46393]; S(item); - _index_id_46377 += 1; + _index_id_46393 += 1; } } @@ -2638,15 +2638,15 @@ fn apply_to_each_ca_callable_defunctionalizes() { { let _array : Qubit[] = register; { - let _range_id_46396 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46399 : Int = _range_id_46396::Start; - let _step_id_46404 : Int = _range_id_46396::Step; - let _end_id_46409 : Int = _range_id_46396::End; - while _step_id_46404 > 0 and _index_id_46399 <= _end_id_46409 or _step_id_46404 < 0 and _index_id_46399 >= _end_id_46409 { - let _index : Int = _index_id_46399; + let _range_id_46412 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46415 : Int = _range_id_46412::Start; + let _step_id_46420 : Int = _range_id_46412::Step; + let _end_id_46425 : Int = _range_id_46412::End; + while _step_id_46420 > 0 and _index_id_46415 <= _end_id_46425 or _step_id_46420 < 0 and _index_id_46415 >= _end_id_46425 { + let _index : Int = _index_id_46415; let item : Qubit = _array[_index]; Adjoint S(item); - _index_id_46399 += _step_id_46404; + _index_id_46415 += _step_id_46420; } } @@ -2656,13 +2656,13 @@ fn apply_to_each_ca_callable_defunctionalizes() { } controlled (ctls, ...) { { - let _array_id_46439 : Qubit[] = register; - let _len_id_46443 : Int = Length(_array_id_46439); - mutable _index_id_46448 : Int = 0; - while _index_id_46448 < _len_id_46443 { - let item : Qubit = _array_id_46439[_index_id_46448]; + let _array_id_46455 : Qubit[] = register; + let _len_id_46459 : Int = Length(_array_id_46455); + mutable _index_id_46464 : Int = 0; + while _index_id_46464 < _len_id_46459 { + let item : Qubit = _array_id_46455[_index_id_46464]; Controlled S(ctls, item); - _index_id_46448 += 1; + _index_id_46464 += 1; } } @@ -2672,15 +2672,15 @@ fn apply_to_each_ca_callable_defunctionalizes() { { let _array : Qubit[] = register; { - let _range_id_46467 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46470 : Int = _range_id_46467::Start; - let _step_id_46475 : Int = _range_id_46467::Step; - let _end_id_46480 : Int = _range_id_46467::End; - while _step_id_46475 > 0 and _index_id_46470 <= _end_id_46480 or _step_id_46475 < 0 and _index_id_46470 >= _end_id_46480 { - let _index : Int = _index_id_46470; + let _range_id_46483 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46486 : Int = _range_id_46483::Start; + let _step_id_46491 : Int = _range_id_46483::Step; + let _end_id_46496 : Int = _range_id_46483::End; + while _step_id_46491 > 0 and _index_id_46486 <= _end_id_46496 or _step_id_46491 < 0 and _index_id_46486 >= _end_id_46496 { + let _index : Int = _index_id_46486; let item : Qubit = _array[_index]; Controlled Adjoint S(ctls, item); - _index_id_46470 += _step_id_46475; + _index_id_46486 += _step_id_46491; } } @@ -2725,13 +2725,13 @@ fn cross_package_apply_to_each_closure_arg_defunctionalizes() { } operation ApplyToEach_Qubit__Empty_(singleElementOperation : (Qubit => Unit), register : Qubit[]) : Unit { { - let _array_id_46213 : Qubit[] = register; - let _len_id_46217 : Int = Length(_array_id_46213); - mutable _index_id_46222 : Int = 0; - while _index_id_46222 < _len_id_46217 { - let item : Qubit = _array_id_46213[_index_id_46222]; + let _array_id_46229 : Qubit[] = register; + let _len_id_46233 : Int = Length(_array_id_46229); + mutable _index_id_46238 : Int = 0; + while _index_id_46238 < _len_id_46233 { + let item : Qubit = _array_id_46229[_index_id_46238]; singleElementOperation(item); - _index_id_46222 += 1; + _index_id_46238 += 1; } } @@ -2756,13 +2756,13 @@ fn cross_package_apply_to_each_closure_arg_defunctionalizes() { } operation ApplyToEach_Qubit__Empty_(singleElementOperation : (Qubit => Unit), register : Qubit[]) : Unit { { - let _array_id_46213 : Qubit[] = register; - let _len_id_46217 : Int = Length(_array_id_46213); - mutable _index_id_46222 : Int = 0; - while _index_id_46222 < _len_id_46217 { - let item : Qubit = _array_id_46213[_index_id_46222]; + let _array_id_46229 : Qubit[] = register; + let _len_id_46233 : Int = Length(_array_id_46229); + mutable _index_id_46238 : Int = 0; + while _index_id_46238 < _len_id_46233 { + let item : Qubit = _array_id_46229[_index_id_46238]; singleElementOperation(item); - _index_id_46222 += 1; + _index_id_46238 += 1; } } @@ -2770,13 +2770,13 @@ fn cross_package_apply_to_each_closure_arg_defunctionalizes() { } operation ApplyToEach_Qubit__Empty__closure_(register : Qubit[], __capture_0 : Double) : Unit { { - let _array_id_46213 : Qubit[] = register; - let _len_id_46217 : Int = Length(_array_id_46213); - mutable _index_id_46222 : Int = 0; - while _index_id_46222 < _len_id_46217 { - let item : Qubit = _array_id_46213[_index_id_46222]; + let _array_id_46229 : Qubit[] = register; + let _len_id_46233 : Int = Length(_array_id_46229); + mutable _index_id_46238 : Int = 0; + while _index_id_46238 < _len_id_46233 { + let item : Qubit = _array_id_46229[_index_id_46238]; _lambda_(__capture_0, item); - _index_id_46222 += 1; + _index_id_46238 += 1; } } @@ -2813,13 +2813,13 @@ fn cross_package_apply_to_each_adjoint_arg_defunctionalizes() { } operation ApplyToEach_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit { { - let _array_id_46213 : Qubit[] = register; - let _len_id_46217 : Int = Length(_array_id_46213); - mutable _index_id_46222 : Int = 0; - while _index_id_46222 < _len_id_46217 { - let item : Qubit = _array_id_46213[_index_id_46222]; + let _array_id_46229 : Qubit[] = register; + let _len_id_46233 : Int = Length(_array_id_46229); + mutable _index_id_46238 : Int = 0; + while _index_id_46238 < _len_id_46233 { + let item : Qubit = _array_id_46229[_index_id_46238]; singleElementOperation(item); - _index_id_46222 += 1; + _index_id_46238 += 1; } } @@ -2840,13 +2840,13 @@ fn cross_package_apply_to_each_adjoint_arg_defunctionalizes() { } operation ApplyToEach_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit { { - let _array_id_46213 : Qubit[] = register; - let _len_id_46217 : Int = Length(_array_id_46213); - mutable _index_id_46222 : Int = 0; - while _index_id_46222 < _len_id_46217 { - let item : Qubit = _array_id_46213[_index_id_46222]; + let _array_id_46229 : Qubit[] = register; + let _len_id_46233 : Int = Length(_array_id_46229); + mutable _index_id_46238 : Int = 0; + while _index_id_46238 < _len_id_46233 { + let item : Qubit = _array_id_46229[_index_id_46238]; singleElementOperation(item); - _index_id_46222 += 1; + _index_id_46238 += 1; } } @@ -2854,13 +2854,13 @@ fn cross_package_apply_to_each_adjoint_arg_defunctionalizes() { } operation ApplyToEach_Qubit__AdjCtl__Adj_S_(register : Qubit[]) : Unit { { - let _array_id_46213 : Qubit[] = register; - let _len_id_46217 : Int = Length(_array_id_46213); - mutable _index_id_46222 : Int = 0; - while _index_id_46222 < _len_id_46217 { - let item : Qubit = _array_id_46213[_index_id_46222]; + let _array_id_46229 : Qubit[] = register; + let _len_id_46233 : Int = Length(_array_id_46229); + mutable _index_id_46238 : Int = 0; + while _index_id_46238 < _len_id_46233 { + let item : Qubit = _array_id_46229[_index_id_46238]; Adjoint S(item); - _index_id_46222 += 1; + _index_id_46238 += 1; } } @@ -2898,13 +2898,13 @@ fn adjoint_cross_package_apply_to_each_ca_defunctionalizes() { operation ApplyToEachCA_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit is Adj + Ctl { body ... { { - let _array_id_46368 : Qubit[] = register; - let _len_id_46372 : Int = Length(_array_id_46368); - mutable _index_id_46377 : Int = 0; - while _index_id_46377 < _len_id_46372 { - let item : Qubit = _array_id_46368[_index_id_46377]; + let _array_id_46384 : Qubit[] = register; + let _len_id_46388 : Int = Length(_array_id_46384); + mutable _index_id_46393 : Int = 0; + while _index_id_46393 < _len_id_46388 { + let item : Qubit = _array_id_46384[_index_id_46393]; singleElementOperation(item); - _index_id_46377 += 1; + _index_id_46393 += 1; } } @@ -2914,15 +2914,15 @@ fn adjoint_cross_package_apply_to_each_ca_defunctionalizes() { { let _array : Qubit[] = register; { - let _range_id_46396 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46399 : Int = _range_id_46396::Start; - let _step_id_46404 : Int = _range_id_46396::Step; - let _end_id_46409 : Int = _range_id_46396::End; - while _step_id_46404 > 0 and _index_id_46399 <= _end_id_46409 or _step_id_46404 < 0 and _index_id_46399 >= _end_id_46409 { - let _index : Int = _index_id_46399; + let _range_id_46412 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46415 : Int = _range_id_46412::Start; + let _step_id_46420 : Int = _range_id_46412::Step; + let _end_id_46425 : Int = _range_id_46412::End; + while _step_id_46420 > 0 and _index_id_46415 <= _end_id_46425 or _step_id_46420 < 0 and _index_id_46415 >= _end_id_46425 { + let _index : Int = _index_id_46415; let item : Qubit = _array[_index]; Adjoint singleElementOperation(item); - _index_id_46399 += _step_id_46404; + _index_id_46415 += _step_id_46420; } } @@ -2932,13 +2932,13 @@ fn adjoint_cross_package_apply_to_each_ca_defunctionalizes() { } controlled (ctls, ...) { { - let _array_id_46439 : Qubit[] = register; - let _len_id_46443 : Int = Length(_array_id_46439); - mutable _index_id_46448 : Int = 0; - while _index_id_46448 < _len_id_46443 { - let item : Qubit = _array_id_46439[_index_id_46448]; + let _array_id_46455 : Qubit[] = register; + let _len_id_46459 : Int = Length(_array_id_46455); + mutable _index_id_46464 : Int = 0; + while _index_id_46464 < _len_id_46459 { + let item : Qubit = _array_id_46455[_index_id_46464]; Controlled singleElementOperation(ctls, item); - _index_id_46448 += 1; + _index_id_46464 += 1; } } @@ -2948,15 +2948,15 @@ fn adjoint_cross_package_apply_to_each_ca_defunctionalizes() { { let _array : Qubit[] = register; { - let _range_id_46467 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46470 : Int = _range_id_46467::Start; - let _step_id_46475 : Int = _range_id_46467::Step; - let _end_id_46480 : Int = _range_id_46467::End; - while _step_id_46475 > 0 and _index_id_46470 <= _end_id_46480 or _step_id_46475 < 0 and _index_id_46470 >= _end_id_46480 { - let _index : Int = _index_id_46470; + let _range_id_46483 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46486 : Int = _range_id_46483::Start; + let _step_id_46491 : Int = _range_id_46483::Step; + let _end_id_46496 : Int = _range_id_46483::End; + while _step_id_46491 > 0 and _index_id_46486 <= _end_id_46496 or _step_id_46491 < 0 and _index_id_46486 >= _end_id_46496 { + let _index : Int = _index_id_46486; let item : Qubit = _array[_index]; Controlled Adjoint singleElementOperation(ctls, item); - _index_id_46470 += _step_id_46475; + _index_id_46486 += _step_id_46491; } } @@ -2981,13 +2981,13 @@ fn adjoint_cross_package_apply_to_each_ca_defunctionalizes() { operation ApplyToEachCA_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit is Adj + Ctl { body ... { { - let _array_id_46368 : Qubit[] = register; - let _len_id_46372 : Int = Length(_array_id_46368); - mutable _index_id_46377 : Int = 0; - while _index_id_46377 < _len_id_46372 { - let item : Qubit = _array_id_46368[_index_id_46377]; + let _array_id_46384 : Qubit[] = register; + let _len_id_46388 : Int = Length(_array_id_46384); + mutable _index_id_46393 : Int = 0; + while _index_id_46393 < _len_id_46388 { + let item : Qubit = _array_id_46384[_index_id_46393]; singleElementOperation(item); - _index_id_46377 += 1; + _index_id_46393 += 1; } } @@ -2997,15 +2997,15 @@ fn adjoint_cross_package_apply_to_each_ca_defunctionalizes() { { let _array : Qubit[] = register; { - let _range_id_46396 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46399 : Int = _range_id_46396::Start; - let _step_id_46404 : Int = _range_id_46396::Step; - let _end_id_46409 : Int = _range_id_46396::End; - while _step_id_46404 > 0 and _index_id_46399 <= _end_id_46409 or _step_id_46404 < 0 and _index_id_46399 >= _end_id_46409 { - let _index : Int = _index_id_46399; + let _range_id_46412 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46415 : Int = _range_id_46412::Start; + let _step_id_46420 : Int = _range_id_46412::Step; + let _end_id_46425 : Int = _range_id_46412::End; + while _step_id_46420 > 0 and _index_id_46415 <= _end_id_46425 or _step_id_46420 < 0 and _index_id_46415 >= _end_id_46425 { + let _index : Int = _index_id_46415; let item : Qubit = _array[_index]; Adjoint singleElementOperation(item); - _index_id_46399 += _step_id_46404; + _index_id_46415 += _step_id_46420; } } @@ -3015,13 +3015,13 @@ fn adjoint_cross_package_apply_to_each_ca_defunctionalizes() { } controlled (ctls, ...) { { - let _array_id_46439 : Qubit[] = register; - let _len_id_46443 : Int = Length(_array_id_46439); - mutable _index_id_46448 : Int = 0; - while _index_id_46448 < _len_id_46443 { - let item : Qubit = _array_id_46439[_index_id_46448]; + let _array_id_46455 : Qubit[] = register; + let _len_id_46459 : Int = Length(_array_id_46455); + mutable _index_id_46464 : Int = 0; + while _index_id_46464 < _len_id_46459 { + let item : Qubit = _array_id_46455[_index_id_46464]; Controlled singleElementOperation(ctls, item); - _index_id_46448 += 1; + _index_id_46464 += 1; } } @@ -3031,15 +3031,15 @@ fn adjoint_cross_package_apply_to_each_ca_defunctionalizes() { { let _array : Qubit[] = register; { - let _range_id_46467 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46470 : Int = _range_id_46467::Start; - let _step_id_46475 : Int = _range_id_46467::Step; - let _end_id_46480 : Int = _range_id_46467::End; - while _step_id_46475 > 0 and _index_id_46470 <= _end_id_46480 or _step_id_46475 < 0 and _index_id_46470 >= _end_id_46480 { - let _index : Int = _index_id_46470; + let _range_id_46483 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46486 : Int = _range_id_46483::Start; + let _step_id_46491 : Int = _range_id_46483::Step; + let _end_id_46496 : Int = _range_id_46483::End; + while _step_id_46491 > 0 and _index_id_46486 <= _end_id_46496 or _step_id_46491 < 0 and _index_id_46486 >= _end_id_46496 { + let _index : Int = _index_id_46486; let item : Qubit = _array[_index]; Controlled Adjoint singleElementOperation(ctls, item); - _index_id_46470 += _step_id_46475; + _index_id_46486 += _step_id_46491; } } @@ -3051,13 +3051,13 @@ fn adjoint_cross_package_apply_to_each_ca_defunctionalizes() { operation ApplyToEachCA_Qubit__AdjCtl__S_(register : Qubit[]) : Unit is Adj + Ctl { body ... { { - let _array_id_46368 : Qubit[] = register; - let _len_id_46372 : Int = Length(_array_id_46368); - mutable _index_id_46377 : Int = 0; - while _index_id_46377 < _len_id_46372 { - let item : Qubit = _array_id_46368[_index_id_46377]; + let _array_id_46384 : Qubit[] = register; + let _len_id_46388 : Int = Length(_array_id_46384); + mutable _index_id_46393 : Int = 0; + while _index_id_46393 < _len_id_46388 { + let item : Qubit = _array_id_46384[_index_id_46393]; S(item); - _index_id_46377 += 1; + _index_id_46393 += 1; } } @@ -3067,15 +3067,15 @@ fn adjoint_cross_package_apply_to_each_ca_defunctionalizes() { { let _array : Qubit[] = register; { - let _range_id_46396 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46399 : Int = _range_id_46396::Start; - let _step_id_46404 : Int = _range_id_46396::Step; - let _end_id_46409 : Int = _range_id_46396::End; - while _step_id_46404 > 0 and _index_id_46399 <= _end_id_46409 or _step_id_46404 < 0 and _index_id_46399 >= _end_id_46409 { - let _index : Int = _index_id_46399; + let _range_id_46412 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46415 : Int = _range_id_46412::Start; + let _step_id_46420 : Int = _range_id_46412::Step; + let _end_id_46425 : Int = _range_id_46412::End; + while _step_id_46420 > 0 and _index_id_46415 <= _end_id_46425 or _step_id_46420 < 0 and _index_id_46415 >= _end_id_46425 { + let _index : Int = _index_id_46415; let item : Qubit = _array[_index]; Adjoint S(item); - _index_id_46399 += _step_id_46404; + _index_id_46415 += _step_id_46420; } } @@ -3085,13 +3085,13 @@ fn adjoint_cross_package_apply_to_each_ca_defunctionalizes() { } controlled (ctls, ...) { { - let _array_id_46439 : Qubit[] = register; - let _len_id_46443 : Int = Length(_array_id_46439); - mutable _index_id_46448 : Int = 0; - while _index_id_46448 < _len_id_46443 { - let item : Qubit = _array_id_46439[_index_id_46448]; + let _array_id_46455 : Qubit[] = register; + let _len_id_46459 : Int = Length(_array_id_46455); + mutable _index_id_46464 : Int = 0; + while _index_id_46464 < _len_id_46459 { + let item : Qubit = _array_id_46455[_index_id_46464]; Controlled S(ctls, item); - _index_id_46448 += 1; + _index_id_46464 += 1; } } @@ -3101,15 +3101,15 @@ fn adjoint_cross_package_apply_to_each_ca_defunctionalizes() { { let _array : Qubit[] = register; { - let _range_id_46467 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46470 : Int = _range_id_46467::Start; - let _step_id_46475 : Int = _range_id_46467::Step; - let _end_id_46480 : Int = _range_id_46467::End; - while _step_id_46475 > 0 and _index_id_46470 <= _end_id_46480 or _step_id_46475 < 0 and _index_id_46470 >= _end_id_46480 { - let _index : Int = _index_id_46470; + let _range_id_46483 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46486 : Int = _range_id_46483::Start; + let _step_id_46491 : Int = _range_id_46483::Step; + let _end_id_46496 : Int = _range_id_46483::End; + while _step_id_46491 > 0 and _index_id_46486 <= _end_id_46496 or _step_id_46491 < 0 and _index_id_46486 >= _end_id_46496 { + let _index : Int = _index_id_46486; let item : Qubit = _array[_index]; Controlled Adjoint S(ctls, item); - _index_id_46470 += _step_id_46475; + _index_id_46486 += _step_id_46491; } } @@ -3189,13 +3189,13 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { operation ApplyToEachCA_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit is Adj + Ctl { body ... { { - let _array_id_46368 : Qubit[] = register; - let _len_id_46372 : Int = Length(_array_id_46368); - mutable _index_id_46377 : Int = 0; - while _index_id_46377 < _len_id_46372 { - let item : Qubit = _array_id_46368[_index_id_46377]; + let _array_id_46384 : Qubit[] = register; + let _len_id_46388 : Int = Length(_array_id_46384); + mutable _index_id_46393 : Int = 0; + while _index_id_46393 < _len_id_46388 { + let item : Qubit = _array_id_46384[_index_id_46393]; singleElementOperation(item); - _index_id_46377 += 1; + _index_id_46393 += 1; } } @@ -3205,15 +3205,15 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { { let _array : Qubit[] = register; { - let _range_id_46396 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46399 : Int = _range_id_46396::Start; - let _step_id_46404 : Int = _range_id_46396::Step; - let _end_id_46409 : Int = _range_id_46396::End; - while _step_id_46404 > 0 and _index_id_46399 <= _end_id_46409 or _step_id_46404 < 0 and _index_id_46399 >= _end_id_46409 { - let _index : Int = _index_id_46399; + let _range_id_46412 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46415 : Int = _range_id_46412::Start; + let _step_id_46420 : Int = _range_id_46412::Step; + let _end_id_46425 : Int = _range_id_46412::End; + while _step_id_46420 > 0 and _index_id_46415 <= _end_id_46425 or _step_id_46420 < 0 and _index_id_46415 >= _end_id_46425 { + let _index : Int = _index_id_46415; let item : Qubit = _array[_index]; Adjoint singleElementOperation(item); - _index_id_46399 += _step_id_46404; + _index_id_46415 += _step_id_46420; } } @@ -3223,13 +3223,13 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { } controlled (ctls, ...) { { - let _array_id_46439 : Qubit[] = register; - let _len_id_46443 : Int = Length(_array_id_46439); - mutable _index_id_46448 : Int = 0; - while _index_id_46448 < _len_id_46443 { - let item : Qubit = _array_id_46439[_index_id_46448]; + let _array_id_46455 : Qubit[] = register; + let _len_id_46459 : Int = Length(_array_id_46455); + mutable _index_id_46464 : Int = 0; + while _index_id_46464 < _len_id_46459 { + let item : Qubit = _array_id_46455[_index_id_46464]; Controlled singleElementOperation(ctls, item); - _index_id_46448 += 1; + _index_id_46464 += 1; } } @@ -3239,15 +3239,15 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { { let _array : Qubit[] = register; { - let _range_id_46467 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46470 : Int = _range_id_46467::Start; - let _step_id_46475 : Int = _range_id_46467::Step; - let _end_id_46480 : Int = _range_id_46467::End; - while _step_id_46475 > 0 and _index_id_46470 <= _end_id_46480 or _step_id_46475 < 0 and _index_id_46470 >= _end_id_46480 { - let _index : Int = _index_id_46470; + let _range_id_46483 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46486 : Int = _range_id_46483::Start; + let _step_id_46491 : Int = _range_id_46483::Step; + let _end_id_46496 : Int = _range_id_46483::End; + while _step_id_46491 > 0 and _index_id_46486 <= _end_id_46496 or _step_id_46491 < 0 and _index_id_46486 >= _end_id_46496 { + let _index : Int = _index_id_46486; let item : Qubit = _array[_index]; Controlled Adjoint singleElementOperation(ctls, item); - _index_id_46470 += _step_id_46475; + _index_id_46486 += _step_id_46491; } } @@ -3302,13 +3302,13 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { operation ApplyToEachCA_Qubit__AdjCtl_(singleElementOperation : (Qubit => Unit is Adj + Ctl), register : Qubit[]) : Unit is Adj + Ctl { body ... { { - let _array_id_46368 : Qubit[] = register; - let _len_id_46372 : Int = Length(_array_id_46368); - mutable _index_id_46377 : Int = 0; - while _index_id_46377 < _len_id_46372 { - let item : Qubit = _array_id_46368[_index_id_46377]; + let _array_id_46384 : Qubit[] = register; + let _len_id_46388 : Int = Length(_array_id_46384); + mutable _index_id_46393 : Int = 0; + while _index_id_46393 < _len_id_46388 { + let item : Qubit = _array_id_46384[_index_id_46393]; singleElementOperation(item); - _index_id_46377 += 1; + _index_id_46393 += 1; } } @@ -3318,15 +3318,15 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { { let _array : Qubit[] = register; { - let _range_id_46396 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46399 : Int = _range_id_46396::Start; - let _step_id_46404 : Int = _range_id_46396::Step; - let _end_id_46409 : Int = _range_id_46396::End; - while _step_id_46404 > 0 and _index_id_46399 <= _end_id_46409 or _step_id_46404 < 0 and _index_id_46399 >= _end_id_46409 { - let _index : Int = _index_id_46399; + let _range_id_46412 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46415 : Int = _range_id_46412::Start; + let _step_id_46420 : Int = _range_id_46412::Step; + let _end_id_46425 : Int = _range_id_46412::End; + while _step_id_46420 > 0 and _index_id_46415 <= _end_id_46425 or _step_id_46420 < 0 and _index_id_46415 >= _end_id_46425 { + let _index : Int = _index_id_46415; let item : Qubit = _array[_index]; Adjoint singleElementOperation(item); - _index_id_46399 += _step_id_46404; + _index_id_46415 += _step_id_46420; } } @@ -3336,13 +3336,13 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { } controlled (ctls, ...) { { - let _array_id_46439 : Qubit[] = register; - let _len_id_46443 : Int = Length(_array_id_46439); - mutable _index_id_46448 : Int = 0; - while _index_id_46448 < _len_id_46443 { - let item : Qubit = _array_id_46439[_index_id_46448]; + let _array_id_46455 : Qubit[] = register; + let _len_id_46459 : Int = Length(_array_id_46455); + mutable _index_id_46464 : Int = 0; + while _index_id_46464 < _len_id_46459 { + let item : Qubit = _array_id_46455[_index_id_46464]; Controlled singleElementOperation(ctls, item); - _index_id_46448 += 1; + _index_id_46464 += 1; } } @@ -3352,15 +3352,15 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { { let _array : Qubit[] = register; { - let _range_id_46467 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46470 : Int = _range_id_46467::Start; - let _step_id_46475 : Int = _range_id_46467::Step; - let _end_id_46480 : Int = _range_id_46467::End; - while _step_id_46475 > 0 and _index_id_46470 <= _end_id_46480 or _step_id_46475 < 0 and _index_id_46470 >= _end_id_46480 { - let _index : Int = _index_id_46470; + let _range_id_46483 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46486 : Int = _range_id_46483::Start; + let _step_id_46491 : Int = _range_id_46483::Step; + let _end_id_46496 : Int = _range_id_46483::End; + while _step_id_46491 > 0 and _index_id_46486 <= _end_id_46496 or _step_id_46491 < 0 and _index_id_46486 >= _end_id_46496 { + let _index : Int = _index_id_46486; let item : Qubit = _array[_index]; Controlled Adjoint singleElementOperation(ctls, item); - _index_id_46470 += _step_id_46475; + _index_id_46486 += _step_id_46491; } } @@ -3375,13 +3375,13 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { operation ApplyToEachCA_Qubit__AdjCtl__X_(register : Qubit[]) : Unit is Adj + Ctl { body ... { { - let _array_id_46368 : Qubit[] = register; - let _len_id_46372 : Int = Length(_array_id_46368); - mutable _index_id_46377 : Int = 0; - while _index_id_46377 < _len_id_46372 { - let item : Qubit = _array_id_46368[_index_id_46377]; + let _array_id_46384 : Qubit[] = register; + let _len_id_46388 : Int = Length(_array_id_46384); + mutable _index_id_46393 : Int = 0; + while _index_id_46393 < _len_id_46388 { + let item : Qubit = _array_id_46384[_index_id_46393]; X(item); - _index_id_46377 += 1; + _index_id_46393 += 1; } } @@ -3391,15 +3391,15 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { { let _array : Qubit[] = register; { - let _range_id_46396 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46399 : Int = _range_id_46396::Start; - let _step_id_46404 : Int = _range_id_46396::Step; - let _end_id_46409 : Int = _range_id_46396::End; - while _step_id_46404 > 0 and _index_id_46399 <= _end_id_46409 or _step_id_46404 < 0 and _index_id_46399 >= _end_id_46409 { - let _index : Int = _index_id_46399; + let _range_id_46412 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46415 : Int = _range_id_46412::Start; + let _step_id_46420 : Int = _range_id_46412::Step; + let _end_id_46425 : Int = _range_id_46412::End; + while _step_id_46420 > 0 and _index_id_46415 <= _end_id_46425 or _step_id_46420 < 0 and _index_id_46415 >= _end_id_46425 { + let _index : Int = _index_id_46415; let item : Qubit = _array[_index]; Adjoint X(item); - _index_id_46399 += _step_id_46404; + _index_id_46415 += _step_id_46420; } } @@ -3409,13 +3409,13 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { } controlled (ctls, ...) { { - let _array_id_46439 : Qubit[] = register; - let _len_id_46443 : Int = Length(_array_id_46439); - mutable _index_id_46448 : Int = 0; - while _index_id_46448 < _len_id_46443 { - let item : Qubit = _array_id_46439[_index_id_46448]; + let _array_id_46455 : Qubit[] = register; + let _len_id_46459 : Int = Length(_array_id_46455); + mutable _index_id_46464 : Int = 0; + while _index_id_46464 < _len_id_46459 { + let item : Qubit = _array_id_46455[_index_id_46464]; Controlled X(ctls, item); - _index_id_46448 += 1; + _index_id_46464 += 1; } } @@ -3425,15 +3425,15 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { { let _array : Qubit[] = register; { - let _range_id_46467 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46470 : Int = _range_id_46467::Start; - let _step_id_46475 : Int = _range_id_46467::Step; - let _end_id_46480 : Int = _range_id_46467::End; - while _step_id_46475 > 0 and _index_id_46470 <= _end_id_46480 or _step_id_46475 < 0 and _index_id_46470 >= _end_id_46480 { - let _index : Int = _index_id_46470; + let _range_id_46483 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46486 : Int = _range_id_46483::Start; + let _step_id_46491 : Int = _range_id_46483::Step; + let _end_id_46496 : Int = _range_id_46483::End; + while _step_id_46491 > 0 and _index_id_46486 <= _end_id_46496 or _step_id_46491 < 0 and _index_id_46486 >= _end_id_46496 { + let _index : Int = _index_id_46486; let item : Qubit = _array[_index]; Controlled Adjoint X(ctls, item); - _index_id_46470 += _step_id_46475; + _index_id_46486 += _step_id_46491; } } @@ -3445,13 +3445,13 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { operation ApplyToEachCA_Qubit__AdjCtl__H_(register : Qubit[]) : Unit is Adj + Ctl { body ... { { - let _array_id_46368 : Qubit[] = register; - let _len_id_46372 : Int = Length(_array_id_46368); - mutable _index_id_46377 : Int = 0; - while _index_id_46377 < _len_id_46372 { - let item : Qubit = _array_id_46368[_index_id_46377]; + let _array_id_46384 : Qubit[] = register; + let _len_id_46388 : Int = Length(_array_id_46384); + mutable _index_id_46393 : Int = 0; + while _index_id_46393 < _len_id_46388 { + let item : Qubit = _array_id_46384[_index_id_46393]; H(item); - _index_id_46377 += 1; + _index_id_46393 += 1; } } @@ -3461,15 +3461,15 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { { let _array : Qubit[] = register; { - let _range_id_46396 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46399 : Int = _range_id_46396::Start; - let _step_id_46404 : Int = _range_id_46396::Step; - let _end_id_46409 : Int = _range_id_46396::End; - while _step_id_46404 > 0 and _index_id_46399 <= _end_id_46409 or _step_id_46404 < 0 and _index_id_46399 >= _end_id_46409 { - let _index : Int = _index_id_46399; + let _range_id_46412 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46415 : Int = _range_id_46412::Start; + let _step_id_46420 : Int = _range_id_46412::Step; + let _end_id_46425 : Int = _range_id_46412::End; + while _step_id_46420 > 0 and _index_id_46415 <= _end_id_46425 or _step_id_46420 < 0 and _index_id_46415 >= _end_id_46425 { + let _index : Int = _index_id_46415; let item : Qubit = _array[_index]; Adjoint H(item); - _index_id_46399 += _step_id_46404; + _index_id_46415 += _step_id_46420; } } @@ -3479,13 +3479,13 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { } controlled (ctls, ...) { { - let _array_id_46439 : Qubit[] = register; - let _len_id_46443 : Int = Length(_array_id_46439); - mutable _index_id_46448 : Int = 0; - while _index_id_46448 < _len_id_46443 { - let item : Qubit = _array_id_46439[_index_id_46448]; + let _array_id_46455 : Qubit[] = register; + let _len_id_46459 : Int = Length(_array_id_46455); + mutable _index_id_46464 : Int = 0; + while _index_id_46464 < _len_id_46459 { + let item : Qubit = _array_id_46455[_index_id_46464]; Controlled H(ctls, item); - _index_id_46448 += 1; + _index_id_46464 += 1; } } @@ -3495,15 +3495,15 @@ fn controlled_apply_to_each_ca_keeps_body_callable_static() { { let _array : Qubit[] = register; { - let _range_id_46467 : Range = Length(_array) - 1..-1..0; - mutable _index_id_46470 : Int = _range_id_46467::Start; - let _step_id_46475 : Int = _range_id_46467::Step; - let _end_id_46480 : Int = _range_id_46467::End; - while _step_id_46475 > 0 and _index_id_46470 <= _end_id_46480 or _step_id_46475 < 0 and _index_id_46470 >= _end_id_46480 { - let _index : Int = _index_id_46470; + let _range_id_46483 : Range = Length(_array) - 1..-1..0; + mutable _index_id_46486 : Int = _range_id_46483::Start; + let _step_id_46491 : Int = _range_id_46483::Step; + let _end_id_46496 : Int = _range_id_46483::End; + while _step_id_46491 > 0 and _index_id_46486 <= _end_id_46496 or _step_id_46491 < 0 and _index_id_46486 >= _end_id_46496 { + let _index : Int = _index_id_46486; let item : Qubit = _array[_index]; Controlled Adjoint H(ctls, item); - _index_id_46470 += _step_id_46475; + _index_id_46486 += _step_id_46491; } } @@ -3545,13 +3545,13 @@ fn cross_package_mapped_defunctionalizes() { function Mapped_Int__Int_(mapper : (Int -> Int), array : Int[]) : Int[] { mutable mapped : Int[] = []; { - let _array_id_45727 : Int[] = array; - let _len_id_45731 : Int = Length(_array_id_45727); - mutable _index_id_45736 : Int = 0; - while _index_id_45736 < _len_id_45731 { - let element : Int = _array_id_45727[_index_id_45736]; + let _array_id_45743 : Int[] = array; + let _len_id_45747 : Int = Length(_array_id_45743); + mutable _index_id_45752 : Int = 0; + while _index_id_45752 < _len_id_45747 { + let element : Int = _array_id_45743[_index_id_45752]; mapped += [mapper(element)]; - _index_id_45736 += 1; + _index_id_45752 += 1; } } @@ -3576,13 +3576,13 @@ fn cross_package_mapped_defunctionalizes() { function Mapped_Int__Int_(mapper : (Int -> Int), array : Int[]) : Int[] { mutable mapped : Int[] = []; { - let _array_id_45727 : Int[] = array; - let _len_id_45731 : Int = Length(_array_id_45727); - mutable _index_id_45736 : Int = 0; - while _index_id_45736 < _len_id_45731 { - let element : Int = _array_id_45727[_index_id_45736]; + let _array_id_45743 : Int[] = array; + let _len_id_45747 : Int = Length(_array_id_45743); + mutable _index_id_45752 : Int = 0; + while _index_id_45752 < _len_id_45747 { + let element : Int = _array_id_45743[_index_id_45752]; mapped += [mapper(element)]; - _index_id_45736 += 1; + _index_id_45752 += 1; } } @@ -3595,13 +3595,13 @@ fn cross_package_mapped_defunctionalizes() { function Mapped_Int__Int__Double_(array : Int[]) : Int[] { mutable mapped : Int[] = []; { - let _array_id_45727 : Int[] = array; - let _len_id_45731 : Int = Length(_array_id_45727); - mutable _index_id_45736 : Int = 0; - while _index_id_45736 < _len_id_45731 { - let element : Int = _array_id_45727[_index_id_45736]; + let _array_id_45743 : Int[] = array; + let _len_id_45747 : Int = Length(_array_id_45743); + mutable _index_id_45752 : Int = 0; + while _index_id_45752 < _len_id_45747 { + let element : Int = _array_id_45743[_index_id_45752]; mapped += [Double(element)]; - _index_id_45736 += 1; + _index_id_45752 += 1; } } @@ -3640,13 +3640,13 @@ fn cross_package_for_each_defunctionalizes() { operation ForEach_Qubit__Unit__AdjCtl_(action : (Qubit => Unit is Adj + Ctl), array : Qubit[]) : Unit[] { mutable output : Unit[] = []; { - let _array_id_45499 : Qubit[] = array; - let _len_id_45503 : Int = Length(_array_id_45499); - mutable _index_id_45508 : Int = 0; - while _index_id_45508 < _len_id_45503 { - let element : Qubit = _array_id_45499[_index_id_45508]; + let _array_id_45515 : Qubit[] = array; + let _len_id_45519 : Int = Length(_array_id_45515); + mutable _index_id_45524 : Int = 0; + while _index_id_45524 < _len_id_45519 { + let element : Qubit = _array_id_45515[_index_id_45524]; output += [action(element)]; - _index_id_45508 += 1; + _index_id_45524 += 1; } } @@ -3669,13 +3669,13 @@ fn cross_package_for_each_defunctionalizes() { operation ForEach_Qubit__Unit__AdjCtl_(action : (Qubit => Unit is Adj + Ctl), array : Qubit[]) : Unit[] { mutable output : Unit[] = []; { - let _array_id_45499 : Qubit[] = array; - let _len_id_45503 : Int = Length(_array_id_45499); - mutable _index_id_45508 : Int = 0; - while _index_id_45508 < _len_id_45503 { - let element : Qubit = _array_id_45499[_index_id_45508]; + let _array_id_45515 : Qubit[] = array; + let _len_id_45519 : Int = Length(_array_id_45515); + mutable _index_id_45524 : Int = 0; + while _index_id_45524 < _len_id_45519 { + let element : Qubit = _array_id_45515[_index_id_45524]; output += [action(element)]; - _index_id_45508 += 1; + _index_id_45524 += 1; } } @@ -3685,13 +3685,13 @@ fn cross_package_for_each_defunctionalizes() { operation ForEach_Qubit__Unit__AdjCtl__H_(array : Qubit[]) : Unit[] { mutable output : Unit[] = []; { - let _array_id_45499 : Qubit[] = array; - let _len_id_45503 : Int = Length(_array_id_45499); - mutable _index_id_45508 : Int = 0; - while _index_id_45508 < _len_id_45503 { - let element : Qubit = _array_id_45499[_index_id_45508]; + let _array_id_45515 : Qubit[] = array; + let _len_id_45519 : Int = Length(_array_id_45515); + mutable _index_id_45524 : Int = 0; + while _index_id_45524 < _len_id_45519 { + let element : Qubit = _array_id_45515[_index_id_45524]; output += [H(element)]; - _index_id_45508 += 1; + _index_id_45524 += 1; } } @@ -3737,13 +3737,13 @@ fn stdlib_hof_specialized_with_concrete_callable() { function Mapped_Int__Int_(mapper : (Int -> Int), array : Int[]) : Int[] { mutable mapped : Int[] = []; { - let _array_id_45727 : Int[] = array; - let _len_id_45731 : Int = Length(_array_id_45727); - mutable _index_id_45736 : Int = 0; - while _index_id_45736 < _len_id_45731 { - let element : Int = _array_id_45727[_index_id_45736]; + let _array_id_45743 : Int[] = array; + let _len_id_45747 : Int = Length(_array_id_45743); + mutable _index_id_45752 : Int = 0; + while _index_id_45752 < _len_id_45747 { + let element : Int = _array_id_45743[_index_id_45752]; mapped += [mapper(element)]; - _index_id_45736 += 1; + _index_id_45752 += 1; } } @@ -3768,13 +3768,13 @@ fn stdlib_hof_specialized_with_concrete_callable() { function Mapped_Int__Int_(mapper : (Int -> Int), array : Int[]) : Int[] { mutable mapped : Int[] = []; { - let _array_id_45727 : Int[] = array; - let _len_id_45731 : Int = Length(_array_id_45727); - mutable _index_id_45736 : Int = 0; - while _index_id_45736 < _len_id_45731 { - let element : Int = _array_id_45727[_index_id_45736]; + let _array_id_45743 : Int[] = array; + let _len_id_45747 : Int = Length(_array_id_45743); + mutable _index_id_45752 : Int = 0; + while _index_id_45752 < _len_id_45747 { + let element : Int = _array_id_45743[_index_id_45752]; mapped += [mapper(element)]; - _index_id_45736 += 1; + _index_id_45752 += 1; } } @@ -3787,13 +3787,13 @@ fn stdlib_hof_specialized_with_concrete_callable() { function Mapped_Int__Int__closure_(array : Int[]) : Int[] { mutable mapped : Int[] = []; { - let _array_id_45727 : Int[] = array; - let _len_id_45731 : Int = Length(_array_id_45727); - mutable _index_id_45736 : Int = 0; - while _index_id_45736 < _len_id_45731 { - let element : Int = _array_id_45727[_index_id_45736]; + let _array_id_45743 : Int[] = array; + let _len_id_45747 : Int = Length(_array_id_45743); + mutable _index_id_45752 : Int = 0; + while _index_id_45752 < _len_id_45747 { + let element : Int = _array_id_45743[_index_id_45752]; mapped += [_lambda_(element, )]; - _index_id_45736 += 1; + _index_id_45752 += 1; } } @@ -3854,13 +3854,13 @@ fn lambda_expression_sample_shape_has_no_defunctionalization_errors() { function Fold_Int__Int_(folder : ((Int, Int) -> Int), state : Int, array : Int[]) : Int { mutable current : Int = state; { - let _array_id_45471 : Int[] = array; - let _len_id_45475 : Int = Length(_array_id_45471); - mutable _index_id_45480 : Int = 0; - while _index_id_45480 < _len_id_45475 { - let element : Int = _array_id_45471[_index_id_45480]; + let _array_id_45487 : Int[] = array; + let _len_id_45491 : Int = Length(_array_id_45487); + mutable _index_id_45496 : Int = 0; + while _index_id_45496 < _len_id_45491 { + let element : Int = _array_id_45487[_index_id_45496]; current = folder(current, element); - _index_id_45480 += 1; + _index_id_45496 += 1; } } @@ -3870,13 +3870,13 @@ fn lambda_expression_sample_shape_has_no_defunctionalization_errors() { function Mapped_Int__Int_(mapper : (Int -> Int), array : Int[]) : Int[] { mutable mapped : Int[] = []; { - let _array_id_45727 : Int[] = array; - let _len_id_45731 : Int = Length(_array_id_45727); - mutable _index_id_45736 : Int = 0; - while _index_id_45736 < _len_id_45731 { - let element : Int = _array_id_45727[_index_id_45736]; + let _array_id_45743 : Int[] = array; + let _len_id_45747 : Int = Length(_array_id_45743); + mutable _index_id_45752 : Int = 0; + while _index_id_45752 < _len_id_45747 { + let element : Int = _array_id_45743[_index_id_45752]; mapped += [mapper(element)]; - _index_id_45736 += 1; + _index_id_45752 += 1; } } @@ -3914,13 +3914,13 @@ fn lambda_expression_sample_shape_has_no_defunctionalization_errors() { function Fold_Int__Int_(folder : ((Int, Int) -> Int), state : Int, array : Int[]) : Int { mutable current : Int = state; { - let _array_id_45471 : Int[] = array; - let _len_id_45475 : Int = Length(_array_id_45471); - mutable _index_id_45480 : Int = 0; - while _index_id_45480 < _len_id_45475 { - let element : Int = _array_id_45471[_index_id_45480]; + let _array_id_45487 : Int[] = array; + let _len_id_45491 : Int = Length(_array_id_45487); + mutable _index_id_45496 : Int = 0; + while _index_id_45496 < _len_id_45491 { + let element : Int = _array_id_45487[_index_id_45496]; current = folder(current, element); - _index_id_45480 += 1; + _index_id_45496 += 1; } } @@ -3930,13 +3930,13 @@ fn lambda_expression_sample_shape_has_no_defunctionalization_errors() { function Mapped_Int__Int_(mapper : (Int -> Int), array : Int[]) : Int[] { mutable mapped : Int[] = []; { - let _array_id_45727 : Int[] = array; - let _len_id_45731 : Int = Length(_array_id_45727); - mutable _index_id_45736 : Int = 0; - while _index_id_45736 < _len_id_45731 { - let element : Int = _array_id_45727[_index_id_45736]; + let _array_id_45743 : Int[] = array; + let _len_id_45747 : Int = Length(_array_id_45743); + mutable _index_id_45752 : Int = 0; + while _index_id_45752 < _len_id_45747 { + let element : Int = _array_id_45743[_index_id_45752]; mapped += [mapper(element)]; - _index_id_45736 += 1; + _index_id_45752 += 1; } } @@ -3949,13 +3949,13 @@ fn lambda_expression_sample_shape_has_no_defunctionalization_errors() { function Fold_Int__Int__closure_(state : Int, array : Int[]) : Int { mutable current : Int = state; { - let _array_id_45471 : Int[] = array; - let _len_id_45475 : Int = Length(_array_id_45471); - mutable _index_id_45480 : Int = 0; - while _index_id_45480 < _len_id_45475 { - let element : Int = _array_id_45471[_index_id_45480]; + let _array_id_45487 : Int[] = array; + let _len_id_45491 : Int = Length(_array_id_45487); + mutable _index_id_45496 : Int = 0; + while _index_id_45496 < _len_id_45491 { + let element : Int = _array_id_45487[_index_id_45496]; current = _lambda_((current, element), ); - _index_id_45480 += 1; + _index_id_45496 += 1; } } @@ -3965,13 +3965,13 @@ fn lambda_expression_sample_shape_has_no_defunctionalization_errors() { function Mapped_Int__Int__closure_(array : Int[]) : Int[] { mutable mapped : Int[] = []; { - let _array_id_45727 : Int[] = array; - let _len_id_45731 : Int = Length(_array_id_45727); - mutable _index_id_45736 : Int = 0; - while _index_id_45736 < _len_id_45731 { - let element : Int = _array_id_45727[_index_id_45736]; + let _array_id_45743 : Int[] = array; + let _len_id_45747 : Int = Length(_array_id_45743); + mutable _index_id_45752 : Int = 0; + while _index_id_45752 < _len_id_45747 { + let element : Int = _array_id_45743[_index_id_45752]; mapped += [_lambda_(element, )]; - _index_id_45736 += 1; + _index_id_45752 += 1; } } @@ -4058,13 +4058,13 @@ fn partial_application_sample_shape_has_no_defunctionalization_errors() { function Mapped_Int__Int_(mapper : (Int -> Int), array : Int[]) : Int[] { mutable mapped : Int[] = []; { - let _array_id_45727 : Int[] = array; - let _len_id_45731 : Int = Length(_array_id_45727); - mutable _index_id_45736 : Int = 0; - while _index_id_45736 < _len_id_45731 { - let element : Int = _array_id_45727[_index_id_45736]; + let _array_id_45743 : Int[] = array; + let _len_id_45747 : Int = Length(_array_id_45743); + mutable _index_id_45752 : Int = 0; + while _index_id_45752 < _len_id_45747 { + let element : Int = _array_id_45743[_index_id_45752]; mapped += [mapper(element)]; - _index_id_45736 += 1; + _index_id_45752 += 1; } } @@ -4108,13 +4108,13 @@ fn partial_application_sample_shape_has_no_defunctionalization_errors() { function Mapped_Int__Int_(mapper : (Int -> Int), array : Int[]) : Int[] { mutable mapped : Int[] = []; { - let _array_id_45727 : Int[] = array; - let _len_id_45731 : Int = Length(_array_id_45727); - mutable _index_id_45736 : Int = 0; - while _index_id_45736 < _len_id_45731 { - let element : Int = _array_id_45727[_index_id_45736]; + let _array_id_45743 : Int[] = array; + let _len_id_45747 : Int = Length(_array_id_45743); + mutable _index_id_45752 : Int = 0; + while _index_id_45752 < _len_id_45747 { + let element : Int = _array_id_45743[_index_id_45752]; mapped += [mapper(element)]; - _index_id_45736 += 1; + _index_id_45752 += 1; } } @@ -4127,13 +4127,13 @@ fn partial_application_sample_shape_has_no_defunctionalization_errors() { function Mapped_Int__Int__closure_(array : Int[], __capture_0 : Int) : Int[] { mutable mapped : Int[] = []; { - let _array_id_45727 : Int[] = array; - let _len_id_45731 : Int = Length(_array_id_45727); - mutable _index_id_45736 : Int = 0; - while _index_id_45736 < _len_id_45731 { - let element : Int = _array_id_45727[_index_id_45736]; + let _array_id_45743 : Int[] = array; + let _len_id_45747 : Int = Length(_array_id_45743); + mutable _index_id_45752 : Int = 0; + while _index_id_45752 < _len_id_45747 { + let element : Int = _array_id_45743[_index_id_45752]; mapped += [_lambda_(__capture_0, element)]; - _index_id_45736 += 1; + _index_id_45752 += 1; } } diff --git a/source/compiler/qsc_fir_transforms/src/monomorphize/tests.rs b/source/compiler/qsc_fir_transforms/src/monomorphize/tests.rs index a9bbeac2c4..3262e5c54f 100644 --- a/source/compiler/qsc_fir_transforms/src/monomorphize/tests.rs +++ b/source/compiler/qsc_fir_transforms/src/monomorphize/tests.rs @@ -2008,14 +2008,14 @@ fn cross_package_non_intrinsic_generic_specializes() { function MappedByIndex_Int___Int__Int__(mapper : ((Int, Int) -> (Int, Int)), array : Int[]) : (Int, Int)[] { mutable mapped : (Int, Int)[] = []; { - let _range_id_45755 : Range = 0..Length(array) - 1; - mutable _index_id_45758 : Int = _range_id_45755::Start; - let _step_id_45763 : Int = _range_id_45755::Step; - let _end_id_45768 : Int = _range_id_45755::End; - while _step_id_45763 > 0 and _index_id_45758 <= _end_id_45768 or _step_id_45763 < 0 and _index_id_45758 >= _end_id_45768 { - let index : Int = _index_id_45758; + let _range_id_45771 : Range = 0..Length(array) - 1; + mutable _index_id_45774 : Int = _range_id_45771::Start; + let _step_id_45779 : Int = _range_id_45771::Step; + let _end_id_45784 : Int = _range_id_45771::End; + while _step_id_45779 > 0 and _index_id_45774 <= _end_id_45784 or _step_id_45779 < 0 and _index_id_45774 >= _end_id_45784 { + let index : Int = _index_id_45774; mapped += [mapper(index, array[index])]; - _index_id_45758 += _step_id_45763; + _index_id_45774 += _step_id_45779; } } diff --git a/source/compiler/qsc_openqasm_parser/src/semantic/lowerer.rs b/source/compiler/qsc_openqasm_parser/src/semantic/lowerer.rs index 151b6dc5fa..80cf21b185 100644 --- a/source/compiler/qsc_openqasm_parser/src/semantic/lowerer.rs +++ b/source/compiler/qsc_openqasm_parser/src/semantic/lowerer.rs @@ -252,6 +252,7 @@ impl Lowerer { continue; } else if include.filename.to_lowercase() == "qdk.inc" { self.define_mresetzchecked(); + self.define_postselectz(); continue; } @@ -439,6 +440,23 @@ impl Lowerer { } } + fn define_postselectz(&mut self) { + let name = "postselectz"; + let symbol = Symbol::new( + name, + Span::default(), + Type::Function( + vec![Type::Bit(false), Type::Qubit].into(), + Type::Void.into(), + ), + Span::default(), + Default::default(), + ); + if self.symbols.insert_symbol(symbol).is_err() { + self.push_redefined_symbol_error(name, Span::default()); + } + } + /// Define the Qiskit standard gates in the symbol table. /// Qiskit emits QASM3 that can't compile because it omits /// definitions for many gates that aren't included in the diff --git a/source/paulimer/src/outcome_specific_simulation.rs b/source/paulimer/src/outcome_specific_simulation.rs index 9fb9ae5426..75f6cc922a 100644 --- a/source/paulimer/src/outcome_specific_simulation.rs +++ b/source/paulimer/src/outcome_specific_simulation.rs @@ -61,6 +61,10 @@ impl OutcomeSpecificSimulation { pub fn outcome_vector(&self) -> &Vec { &self.outcome_vector } + + pub fn post_select_z(&mut self, value: bool, index: usize) -> Result<(), String> { + measure_pauli_forced(self, &SparsePauli::from([quantum_core::z(index)]), value) + } } pub fn apply_hadamard(simulation: &mut OutcomeSpecificSimulation, qubit_index: usize) { @@ -113,6 +117,7 @@ pub fn measure_pauli_with_hint( simulation: &mut OutcomeSpecificSimulation, observable: &SparsePauli, hint: &PauliUnitary, + forced_bit: Option, ) { assert!( anti_commutes_with(observable, hint), @@ -127,7 +132,16 @@ pub fn measure_pauli_with_hint( let mut pauli = observable.clone() * hint; pauli *= Phase::from_exponent(3u8.wrapping_sub(preimage.xz_phase_exponent().raw_value())); PauliExponent::new(pauli) * &mut simulation.clifford; - allocate_random_bit(simulation); + if let Some(forced) = forced_bit { + // Since we have a forced bit, use that as ther result instead of a random one. + // To keep the internal state consistent, we also mark this as a random outcome, + // incrementing the count as well. + simulation.outcome_vector.push(forced); + simulation.random_outcome_indicator.push(true); + simulation.num_random_bits += 1; + } else { + allocate_random_bit(simulation); + } apply_conditional_pauli( simulation, hint, @@ -153,12 +167,34 @@ pub fn measure_pauli(simulation: &mut OutcomeSpecificSimulation, observable: &Sp match non_zero_pos { Some(pos) => { let hint = simulation.clifford.image_z(pos); - measure_pauli_with_hint(simulation, observable, &hint); + measure_pauli_with_hint(simulation, observable, &hint, None); + } + None => { + measure_deterministic(simulation, &preimage); + } + } +} + +pub fn measure_pauli_forced( + simulation: &mut OutcomeSpecificSimulation, + observable: &SparsePauli, + forced_bit: bool, +) -> Result<(), String> { + let preimage = simulation.clifford.preimage(observable); + let non_zero_pos = preimage.x_bits().support().next(); + match non_zero_pos { + Some(pos) => { + let hint = simulation.clifford.image_z(pos); + measure_pauli_with_hint(simulation, observable, &hint, Some(forced_bit)); } None => { measure_deterministic(simulation, &preimage); + if simulation.outcome_vector().last() != Some(&forced_bit) { + return Err("post-selection condition has zero probability".into()); + } } } + Ok(()) } fn measure_deterministic( @@ -252,7 +288,7 @@ impl Simulation for OutcomeSpecificSimulation { ) -> usize { let pauli = SparsePauli::from(observable); let hint = SparsePauli::from(hint); - measure_pauli_with_hint(self, &pauli, &hint); + measure_pauli_with_hint(self, &pauli, &hint, None); self.outcome_vector().len() - 1 } diff --git a/source/qdk_package/tests/test_qasm.py b/source/qdk_package/tests/test_qasm.py index b51d8e2bf8..25594f0096 100644 --- a/source/qdk_package/tests/test_qasm.py +++ b/source/qdk_package/tests/test_qasm.py @@ -133,6 +133,56 @@ def test_mresetzchecked_not_present_without_qdk_inc() -> None: assert "undefined symbol: mresetz_checked" in str(excinfo.value) +def test_postselectz_one() -> None: + result = run( + """ + include "stdgates.inc"; + include "qdk.inc"; + qubit q1; + bit r; + h q1; + postselectz(1, q1); + r = measure q1; + """, + shots=100, + seed=0, + ) + assert all(r == Result.One for r in result) + + +def test_postselectz_zero() -> None: + result = run( + """ + include "stdgates.inc"; + include "qdk.inc"; + qubit q1; + bit r; + h q1; + postselectz(0, q1); + r = measure q1; + """, + shots=100, + seed=0, + ) + assert all(r == Result.Zero for r in result) + + +def test_postselectz_not_present_without_qdk_inc() -> None: + with pytest.raises(QasmError) as excinfo: + run( + """ + include "stdgates.inc"; + qubit q1; + bit r; + postselectz(0, q1); + r = measure q1; + """, + shots=100, + seed=0, + ) + assert "undefined symbol: postselectz" in str(excinfo.value) + + def test_run_with_result(capsys) -> None: results = run("output bit c;", 3) assert results == [Result.Zero, Result.Zero, Result.Zero] @@ -310,21 +360,16 @@ def test_compile_qir_str() -> None: def test_compile_qir_str_with_single_arg_raises_error() -> None: init(target_profile=TargetProfile.Base) with pytest.raises(QSharpError) as excinfo: - compile( - """ + compile(""" include "stdgates.inc"; input float f; qubit q; rx(f) q; output bit c; c = measure q; - """ - ) - assert ( - str(excinfo.value) - == """Circuit has unbound input parameters + """) + assert str(excinfo.value) == """Circuit has unbound input parameters help: Parameters: f: Double""" - ) # Import + Compile @@ -630,12 +675,10 @@ def test_circuit_from_program() -> None: x q1; """, ) - assert str(c) == dedent( - """\ + assert str(c) == dedent("""\ q_0 ── X ── q_1 ─────── - """ - ) + """) def test_circuit_from_program_static() -> None: @@ -653,12 +696,10 @@ def test_circuit_from_program_static() -> None: """, generation_method=CircuitGenerationMethod.Static, ) - assert str(c) == dedent( - """\ + assert str(c) == dedent("""\ q_0 ── H ──── M ──── if: c_0 = |1〉 ── ╘═══════════ ● ════════ - """ - ) + """) def test_circuit_from_callable() -> None: @@ -674,12 +715,10 @@ def test_circuit_from_callable() -> None: name="Foo", ) c = qsharp_circuit("{ use (q1, q2) = (Qubit(), Qubit()); Foo(q1, q2); }") - assert str(c) == dedent( - """\ + assert str(c) == dedent("""\ q_0 ── X ── q_1 ─────── - """ - ) + """) def test_circuit_from_callable_with_multiple_qubit_registers() -> None: @@ -696,14 +735,12 @@ def test_circuit_from_callable_with_multiple_qubit_registers() -> None: name="Foo", ) c = qsharp_circuit("{ use (qs1, qs2) = (Qubit[2], Qubit[2]); Foo(qs1, qs2); }") - assert str(c) == dedent( - """\ + assert str(c) == dedent("""\ q_0 ── X ── q_1 ─────── q_2 ─────── q_3 ── X ── - """ - ) + """) def test_circuit_from_callable_with_single_qubit_and_qubit_registers() -> None: @@ -724,15 +761,13 @@ def test_circuit_from_callable_with_single_qubit_and_qubit_registers() -> None: c = qsharp_circuit( "{ use (qs1, a, qs2) = (Qubit[2], Qubit(), Qubit[2]); Foo(qs1, a, qs2); }" ) - assert str(c) == dedent( - """\ + assert str(c) == dedent("""\ q_0 ── X ── q_1 ─────── q_2 ── X ── q_3 ─────── q_4 ── X ── - """ - ) + """) def test_circuit_from_callable_with_args() -> None: @@ -749,12 +784,10 @@ def test_circuit_from_callable_with_args() -> None: name="Foo", ) c = qsharp_circuit("{ use qs = Qubit[2]; Foo(2, qs); }") - assert str(c) == dedent( - """\ + assert str(c) == dedent("""\ q_0 ── X ── q_1 ── X ── - """ - ) + """) def test_circuit_with_measure_from_callable() -> None: @@ -764,12 +797,10 @@ def test_circuit_with_measure_from_callable() -> None: name="Foo", ) c = qsharp_circuit("{ use q = Qubit(); Foo(q); }") - assert str(c) == dedent( - """\ + assert str(c) == dedent("""\ q_0 ── H ──── M ── ╘═══ - """ - ) + """) def test_circuit_from_callable_static() -> None: @@ -791,20 +822,17 @@ def test_circuit_from_callable_static() -> None: code.qasm_import.Foo, generation_method=CircuitGenerationMethod.Static, ) - assert str(c) == dedent( - """\ + assert str(c) == dedent("""\ q_0 ── H ──── M ──── if: c_0 = |1〉 ── ╘═══════════ ● ════════ - """ - ) + """) # Estimate def test_qasm_estimation() -> None: - res = estimate( - """ + res = estimate(""" include "stdgates.inc"; const int SIZE = 10; qubit[SIZE] q; @@ -812,8 +840,7 @@ def test_qasm_estimation() -> None: t q[i]; measure q[i]; } - """ - ) + """) assert res["status"] == "success" assert res["physicalCounts"] is not None assert res.logical_counts == LogicalCounts( diff --git a/source/simulators/src/stabilizer_simulator.rs b/source/simulators/src/stabilizer_simulator.rs index 7e59317808..0b1d458401 100644 --- a/source/simulators/src/stabilizer_simulator.rs +++ b/source/simulators/src/stabilizer_simulator.rs @@ -160,6 +160,11 @@ impl StabilizerSimulator { } } + /// Forces the state of a qubit to collapse to a specific value. + pub fn post_select_z(&mut self, result: bool, target: QubitID) -> Result<(), String> { + self.state.post_select_z(result, target) + } + fn apply_gate_in_place(&mut self, gate: &Operation) { match *gate { Operation::I { .. } => (),