Skip to content

Commit f6c270b

Browse files
committed
Final fix to the symmetry breaker.
1 parent e6b0cbf commit f6c270b

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

src/cliffordsynthesis/encoding/MultiGateEncoder.cpp

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -144,36 +144,24 @@ void MultiGateEncoder::assertTwoQubitGateOrderConstraints(
144144
LogicTerm::implies(vars.gC[pos][trgt][ctrl], !gCNext[trgt][ctrl]));
145145

146146
// no gate on both qubits => no CNOT on them in the next time step.
147+
// hadamards on both qubits => no CNOT on them in the next time step (CNOT can
148+
// be conjugated with Hadamards) No Combination of Paulis on both Qubits
149+
// before a CNOT These gates can be just pushed through to the other side
147150
constexpr auto noneIndex = gateToIndex(qc::OpType::None);
148151
const auto noGate = gSNow[noneIndex][ctrl] && gSNow[noneIndex][trgt];
149-
150-
const auto noFurtherCnot = !gCNext[ctrl][trgt] && !gCNext[trgt][ctrl];
151-
// Also:
152-
// No Combination of Paulis or Hadamards on both Qubits before a CNOT
153-
// These gates can be just pushed through to the other side
152+
const auto noFurtherCnot = !gCNext[ctrl][trgt] && !gCNext[trgt][ctrl];
154153

155154
constexpr auto hIndex = gateToIndex(qc::OpType::H);
156155
constexpr auto xIndex = gateToIndex(qc::OpType::X);
157156
constexpr auto zIndex = gateToIndex(qc::OpType::Z);
158157
constexpr auto yIndex = gateToIndex(qc::OpType::Y);
159-
if (pos ==
160-
0) { // In the beginning parallel Pauli and Hadamard gates are allowed
161-
const auto& hh = gSNow[hIndex][ctrl] && gSNow[hIndex][trgt];
162-
const auto gateBeforeCtrl =
163-
gSNow[zIndex][ctrl] || gSNow[xIndex][ctrl] || gSNow[yIndex][ctrl];
164-
const auto gateBeforeTarget =
165-
gSNow[zIndex][trgt] || gSNow[xIndex][trgt] || gSNow[yIndex][ctrl];
166-
LogicTerm::implies(noGate || hh || (gateBeforeCtrl && gateBeforeTarget),
167-
noFurtherCnot);
168-
return;
169-
}
170-
171-
const auto gateBeforeCtrl = gSNow[zIndex][ctrl] || gSNow[xIndex][ctrl] ||
172-
gSNow[yIndex][ctrl] || gSNow[hIndex][ctrl];
173-
const auto gateBeforeTarget = gSNow[zIndex][trgt] || gSNow[xIndex][trgt] ||
174-
gSNow[yIndex][ctrl] || gSNow[hIndex][trgt];
158+
const auto hh = gSNow[hIndex][ctrl] && gSNow[hIndex][trgt];
159+
const auto gateBeforeCtrl =
160+
gSNow[zIndex][ctrl] || gSNow[xIndex][ctrl] || gSNow[yIndex][ctrl];
161+
const auto gateBeforeTarget =
162+
gSNow[zIndex][trgt] || gSNow[xIndex][trgt] || gSNow[yIndex][ctrl];
175163
lb->assertFormula(LogicTerm::implies(
176-
noGate || (gateBeforeCtrl && gateBeforeTarget), noFurtherCnot));
164+
noGate || hh || (gateBeforeCtrl && gateBeforeTarget), noFurtherCnot));
177165
}
178166

179167
void MultiGateEncoder::splitXorR(const logicbase::LogicTerm& changes,

0 commit comments

Comments
 (0)