"The lab turns the oracle story into controlled edits. Each exercise asks you to preserve the question you are asking while changing one part of the mechanism. That discipline matters because algorithm notebooks become noisy very quickly when multiple causal features are changed at once.\n"
" Before each edit, say what should remain invariant and what should change. Then render the circuit, inspect the diagram, inspect the preview counts, and decide whether the result matches the mechanism you think you are testing. If you cannot state the intended invariant, the edit is too loose.\n"
" Start with the smallest circuit and change only the oracle kind. You should be able to explain why the constant and balanced families differ before you run the code. Do not let the count histogram be the first time you decide what the circuit means.\n"
"step_reference_table([{'marker': '[1]', 'code_focus': 'Prepare the query wire in superposition and the ancilla in the |-> state.', 'diagram_effect': 'The left side of the diagram separates the question register from the phase-sensitive ancilla.', 'why_it_matters': 'Without this preparation, the oracle behaves like an ordinary reversible gadget instead of a phase-encoding query.'}, {'marker': '[2]', 'code_focus': 'Apply an oracle that represents a promise class rather than a single numerical answer.', 'diagram_effect': 'The middle region becomes the semantic core of the circuit.', 'why_it_matters': 'Algorithmic design starts when you think in contracts and promise structures rather than in isolated gates.'}, {'marker': '[3]', 'code_focus': 'Use a final Hadamard on the query wire to convert hidden phase information into a measurable bit.', 'diagram_effect': 'The right side of the circuit shows a deliberate interference stage instead of direct readout after the oracle.', 'why_it_matters': 'Interference is the mechanism that cashes out the query advantage.'}, {'marker': '[4]', 'code_focus': 'Measure only the wire that carries the decision information.', 'diagram_effect': 'The reporting layer stays narrow and intentional.', 'why_it_matters': 'Professional design protects the evidence path and avoids measuring wires that are not part of the claim.'}])\n"
" instructions='Switch between constant_zero, constant_one, and balanced. Keep the explanation of the decision wire and the promise class explicit.',\n",
"quiz_block([{'prompt': 'If you change the Deutsch oracle from balanced to constant_zero, what should happen to the measured query bit?', 'options': ['It should reliably flip to 1', 'It should move toward 0 because the phase distinction disappears', 'It should become uniformly random'], 'correct_index': 1, 'explanation': 'A constant oracle does not create the same phase relation, so the final interference returns the constant verdict.'}, {'prompt': 'What is the right way to inspect a circuit edit in this lab?', 'options': ['Change several lines at once so the effect is obvious', 'Change one causal feature at a time and compare the diagram and counts together', 'Ignore the diagram and focus only on the text representation'], 'correct_index': 1, 'explanation': 'Controlled editing is the only way to attach causes to outcomes.'}], heading='Lab Checkpoint A')\n"
" Move to a wider query register without abandoning the same mechanism. The point is to feel what scales and what does not. If your explanation changes from 'promise plus interference' to 'I copied a bigger circuit,' stop and reset.\n"
" The fastest way to discover whether you truly understand the mechanism is to break it on purpose. Remove or alter one preparation step and see whether you can predict exactly which explanatory sentence stops being true. This is a design habit, not just a debugging trick.\n"
"quiz_block([{'prompt': 'What usually happens if you remove the ancilla Hadamard and keep the rest of the Deutsch circuit unchanged?', 'options': ['Phase kickback logic is broken, so the final decision bit loses its meaning', 'The query wire is automatically corrected by transpilation', 'Nothing changes because the ancilla is not measured'], 'correct_index': 0, 'explanation': 'The ancilla preparation is part of the mechanism, not optional decoration.'}, {'prompt': 'Why is Deutsch-Jozsa a useful engineering module and not only a historical algorithm?', 'options': ['It teaches how to scale promise-structured oracles and interference reasoning', 'It is the fastest route to hardware execution', 'It eliminates the need for later algorithm study'], 'correct_index': 0, 'explanation': 'The reusable lesson is how an oracle contract and interference stage compose.'}], heading='Lab Checkpoint B')\n"
" The lab should leave you with a stricter sense of what counts as an explanation. A strong explanation in this module ties the promise class to the oracle body, the ancilla preparation to phase kickback, the final Hadamard to interference, and the measured wire to the actual decision being made. If any of those links felt fuzzy, that is useful information. The whole point of the bundle structure is to surface that fuzziness before later modules assume the pattern is already solid.\n"
"These exercises are intentionally slower than ordinary click-through tutorials because the purpose is different. A tutorial can reward motion. A professional lab has to reward discrimination. You are being asked to notice which edit changed the semantic burden of the circuit, which edit only changed presentation, and which edit damaged the reporting contract even though the diagram still looked familiar. That is harder work, but it is the right work for someone trying to become a designer rather than a consumer of notebooks.\n"
"If the lab begins to feel messy, return to the prediction ledger idea. Before each edit, write down what should remain invariant, what should move, and which evidence will decide the question. That tiny discipline is what keeps experiments from collapsing into aimless button pushing. It also mirrors how real engineering work scales. Good engineers do not only make changes. They keep track of what they expected the change to prove.\n"
"reflection_box('Write a short review note about one Deutsch-Jozsa oracle candidate that looks plausible but does not clearly expose its promise class.')\n"