State-preparation composition¶
oracq.algorithms.common.state_preparation
Composition utilities for initial state extension, applying encodings and physical subspace selection.
- oracq.algorithms.common.state_preparation.extend_initial(prep, extra_width)[source]¶
Extend the target space of a state preparation
prepbyextra_widthhigh bits.The original preparation acts on the low bits of the extended target and the new high bits stay zero; the zero-input promise is preserved.
- Parameters:
prep – The original
StatePreparation.extra_width – Number of high qubits to append.
- Returns:
Preparation whose target width is
prep.width + extra_width.- Return type:
- oracq.algorithms.common.state_preparation.select_subspace(state, output_width, high_value=0, *, label='selection')[source]¶
Select the physical subspace out of the target space of a state oracle.
The low
output_widthbits serve as the output, while the remaining high bits are folded into signal and required to equalhigh_value; the success condition is that the whole signal register returns to zero.- Parameters:
state – The input
StateOracle, with width not less thanoutput_width.output_width – The selected physical output width.
high_value – The value that the discarded high bits must equal, zero by default.
label – Label used for the generated module name and algorithm attribute.
- Returns:
State oracle with output width
output_widthand a signal holding the original signal bits plus the appended high bits.- Return type:
- Raises:
ValidationError –
output_widthexceedsstate.width, orhigh_valueis out of range.
- oracq.algorithms.common.state_preparation.apply_be_to_state(a, prep)[source]¶
Apply a block encoding
ato an already prepared initial state, yielding a state oracle.The signal bits of
aoccupy the low bits of signal and the workspace ofprepis folded into its high bits; the success condition is that the whole signal register returns to zero.- Parameters:
a – The
BlockEncodingof the operator to apply.prep – A
StatePreparationwith the same target width asa.
- Returns:
State oracle with unchanged target width and an attached signal register.
- Return type:
- Raises:
ValidationError – The two target widths differ.