Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unitary hack] Add doc for internal AND #1580

Merged
merged 10 commits into from
Jun 7, 2024
18 changes: 0 additions & 18 deletions library/std/internal.qs
Original file line number Diff line number Diff line change
Expand Up @@ -150,24 +150,6 @@ namespace Microsoft.Quantum.Intrinsic {
}
}

@Config(Adaptive)
internal operation AND(control1 : Qubit, control2 : Qubit, target : Qubit) : Unit is Adj {
body ... {
__quantum__qis__ccx__body(control1, control2, target);
}
adjoint ... {
__quantum__qis__h__body(target);
if MResetZ(target) == One {
__quantum__qis__cz__body(control1, control2);
}
}
}

@Config(not Adaptive)
internal operation AND(control1 : Qubit, control2 : Qubit, target : Qubit) : Unit is Adj {
PhaseCCX(control1, control2, target);
}

internal operation PhaseCCX(control1 : Qubit, control2 : Qubit, target : Qubit) : Unit is Adj {
// https://arxiv.org/pdf/1210.0974.pdf#page=2
H(target);
Expand Down
46 changes: 46 additions & 0 deletions library/std/intrinsic.qs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,52 @@ namespace Microsoft.Quantum.Intrinsic {
open Microsoft.Quantum.Math;
open QIR.Intrinsic;

/// # Summary
/// Applies the AND gate that is more efficient for use with decomposition of multi-controlled operations.
/// Note that target qubit must be in |0⟩ state.
///
/// # Input
/// ## control1
/// First control qubit for the AND gate.
/// ## control2
/// Second control qubit for the AND gate.
/// ## target
/// Target qubit for the AND gate.
///
/// # Remarks
/// Use the Adjoint only for uncomputation purposes.
@Config(Adaptive)
operation AND(control1 : Qubit, control2 : Qubit, target : Qubit) : Unit is Adj {
body ... {
__quantum__qis__ccx__body(control1, control2, target);
}
adjoint ... {
__quantum__qis__h__body(target);
if MResetZ(target) == One {
__quantum__qis__cz__body(control1, control2);
}
}
}

/// # Summary
/// Applies the AND gate that is more efficient for use with decomposition of multi-controlled operations.
/// Note that target qubit must be in |0⟩ state.
///
/// # Input
/// ## control1
/// First control qubit for the AND gate.
/// ## control2
/// Second control qubit for the AND gate.
/// ## target
/// Target qubit for the AND gate.
///
/// # Remarks
/// Use the Adjoint only for uncomputation purposes.
@Config(not Adaptive)
operation AND(control1 : Qubit, control2 : Qubit, target : Qubit) : Unit is Adj {
PhaseCCX(control1, control2, target);
}

/// # Summary
/// Applies the doubly controlled–NOT (CCNOT) gate to three qubits.
///
Expand Down
4 changes: 2 additions & 2 deletions vscode/test/suites/debugger/debugger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,10 @@ suite("Q# Debugger Tests", function suite() {
sourceReference: 0,
adapterData: "qsharp-adapter-data",
},
line: 159,
line: 205,
column: 13,
name: "H ",
endLine: 159,
endLine: 205,
endColumn: 44,
},
{
Expand Down
Loading