In Codercise G.5.1 it is written:
Let’s start by coding up this new oracle. Create an oracle for a random solution set of a given size using the MultiControlledX gate. Remember that this takes a string for control_values (e.g.,"11011") as a parameter rather than a list of bits.
However, when trying to implement the above gate as qp.MultiControlledX(all_wires,control_values=“11011”), it results in a ValueError: control_values must be boolean or int.
Indeed, in the official PennyLane documentation for the qml.MultiControlledX class, it is reported:
control_values (Union[bool, list[bool], int, list[int]]) – The value(s) the control wire(s) should take. Integers other than 0 or 1 will be treated as int(bool(x)).
This is confirmed also by the official solution provided for Codercise G.5.1, which is:
def oracle_multi(combos):
"""Implement multi-solution oracle using sequence of multi-controlled
X gates.
Args:
combos (list[list[int]]): A list of solutions.
"""
for combo in combos:
qp.MultiControlledX(wires=range(n_bits + 1), control_values=combo)
For this reason, I believe that the initial remark about control_values is misleading and should be corrected.