QuantumLearning/notebooks/foundations/module_01_principles_and_circuit_literacy/lecture.ipynb

735 lines
42 KiB
Text

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #2563eb; background:#dbeafe; color:#1e3a8a; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>META READING</strong> · Difficulty 1/10 · Notebook-level rule, objective, or usage guidance.\n",
"</div>\n",
"\n",
"# Principles and Circuit Literacy Lecture\n",
"\n",
"This lecture is the first rebuilt module of the new course architecture. Its purpose is not merely to introduce a few gates. Its purpose is to install the habits of reading that make later circuit design possible. The module sits at the foundation of the entire lecture series because nearly every later failure in algorithmic design, transpilation reasoning, or verification can be traced back to weak early literacy: weak vocabulary, weak diagram reading, weak distinction between preparation and measurement, or weak ability to narrate what a circuit is doing.\n"
],
"id": "d8af6ec7"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #2563eb; background:#dbeafe; color:#1e3a8a; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>META READING</strong> · Difficulty 1/10 · Official walkthrough guardrail.\n",
"</div>\n",
"\n",
"<!-- COURSE_NAV_TOP -->\n",
"## Mainline Navigation\n",
"\n",
"Step 3 of 59. Follow the official walkthrough in order.\n",
"\n",
"Previous notebook: [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n",
"\n",
"Next notebook: [Principles and Circuit Literacy Lab](lab.ipynb)\n",
"\n",
"Rule: complete the mandatory cells in this notebook before you open the next one.\n"
],
"id": "5f8a263d"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #2563eb; background:#dbeafe; color:#1e3a8a; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>META READING</strong> · Difficulty 1/10 · Notebook-level rule, objective, or usage guidance.\n",
"</div>\n",
"\n",
"## Learning Objective\n",
"\n",
"By the end of this lecture, you should be able to do four things with a small Bell-style circuit. First, you should be able to explain its role in plain language without waving your hands and saying that the circuit does “a quantum thing.” Second, you should be able to move between code and diagram without losing your place in time. Third, you should be able to say why a measurement result is the answer to a chosen question rather than a neutral readout of an already classical object. Fourth, you should be able to modify one part of the circuit and state what you expect to change before you run it.\n",
"\n",
"That last requirement is important. A course becomes serious at the exact moment it insists that you predict. Prediction is the first practical signal that explanation has started turning into design control.\n"
],
"id": "4604e39f"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
"</div>\n",
"\n",
"## Why Foundations Need More Than Syntax\n",
"\n",
"Beginners are often told that the first task is just to “get familiar with Qiskit syntax.” That advice is incomplete. Syntax matters, but professional circuit design is not built from syntax alone. Syntax is the surface form of a deeper activity: preparing states, creating structure across wires, changing the basis of the question, and reading the consequences of those changes. If you study only syntax, every later notebook feels like memorizing new incantations. If you study mechanism, later notebooks start to look like recombinations of a much smaller set of structural moves.\n",
"\n",
"The first structural move in this module is the branch. In a simple circuit, a Hadamard gate is not merely a symbol you type. It is the move that destroys the naive single classical path and forces you to think in alternatives, amplitudes, and later interference. The second structural move is correlation. A two-qubit gate placed after a preparation step is not just an instruction on the second wire. It is a statement about how the meaning of that wire now depends on the story already in flight. The third structural move is the question. Measurement tells you what the circuit designer chose to ask of the prepared state. These three moves — branch, correlate, ask — form the skeleton of the first module.\n",
"\n",
"A world-class course needs to slow those moves down enough that you can name them. Otherwise the first circuits feel magical, and magic does not scale to engineering.\n"
],
"id": "536f7109"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
"</div>\n",
"\n",
"## Classical Randomness Versus Quantum Superposition\n",
"\n",
"The temptation at this stage is to use a classical analogy and never let go of it. The spinning coin is the usual example. It is useful because it breaks the rigid “either 0 or 1” intuition. But it is dangerous when learners mistake the analogy for the thing itself. A spinning coin is still a classical object with hidden details. If you knew the force, the surface, the air resistance, the exact initial conditions, and enough mechanics, you would describe its behavior in classical terms. Quantum superposition is not simply ignorance of a classical hidden value. The language of amplitudes, basis states, and phase is not decorative. It is what makes the quantum story structurally different.\n",
"\n",
"This matters for design because the wrong analogy produces the wrong debugging behavior. If you secretly believe that a qubit always had a classical value and measurement merely exposed it, then many circuits will look nonsensical. You will wonder why basis rotations before measurement matter so much, why interference can strengthen some outcomes and suppress others, and why a correlation pattern can emerge that does not reduce cleanly to classical uncertainty. The lecture therefore uses analogy only as a doorway. Once you step through it, the course insists on more precise language.\n",
"\n",
"The correct beginner move is not to pretend you already understand amplitudes fully. The correct move is to stop using classical language in places where it no longer fits. A professional designer is not someone who abandoned intuition. A professional designer is someone whose intuition became precise enough to know where an analogy stops helping.\n"
],
"id": "74aa6f9d"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
"</div>\n",
"\n",
"## How To Read A Circuit\n",
"\n",
"A circuit should be read as a time-ordered argument. The vertical dimension tells you which wires are involved. The horizontal dimension tells you what happens earlier and later. The mistake many amateurs make is to see only symbols. They notice that there is an `h` here, a `cx` there, and a measurement symbol at the end. That is symbol recognition, not circuit literacy. Circuit literacy begins when you can narrate the causal burden of each step.\n",
"\n",
"Consider the Bell-style circuit that anchors this module. The first step places the first qubit into a nontrivial preparation. The second step spreads the consequence of that preparation into a relationship with the second qubit. The final step chooses a measurement basis and stores the answers in classical memory. When learners say “the circuit creates entanglement,” they are not wrong, but they are still skipping the explanation that makes the statement useful. Which line created the branching? Which line turned that branching into a shared relationship? Which line turned the relationship into an empirical result? Those are the questions that convert a diagram from ornament into argument.\n",
"\n",
"This is also why code and graphics must be cross-referenced. A world-class notebook cannot assume that a learner will automatically map one to the other. It must force the translation until it becomes a habit. That is the reason for the marker table and editable lab below.\n"
],
"id": "d4adb37b"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
"</div>\n",
"\n",
"## Why The Bell Circuit Is The Right Anchor\n",
"\n",
"The Bell circuit is small enough to inspect completely and rich enough to train serious habits. It contains a branch point, a structural relationship between wires, and an interpretable measurement signature. That makes it a nearly perfect first anchor. If a learner cannot narrate this circuit cleanly, then larger circuits will only multiply the confusion. If a learner *can* narrate it cleanly, later modules can reuse the same reading habits with harder material.\n",
"\n",
"The deeper reason the Bell circuit matters is that it refuses to tolerate vague explanation. “This creates entanglement” is not useless, but it is too compressed for a learner. Which line creates the branch structure? Which line turns that branch structure into a two-wire relationship? Which line converts the relationship into data? Those more granular questions are the ones that support editing, comparison, and later review.\n"
],
"id": "ff8782ac"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
"</div>\n",
"\n",
"## Representation Switching Is Part Of The Subject\n",
"\n",
"Many technical courses treat multiple representations as a convenience. Quantum computing does not permit that luxury. Even in an introductory module you are already moving between code, circuit picture, histogram, probability dictionary, and explanatory prose. That can feel like too much at first, but the discomfort is pointing at a real feature of the field. Good circuit designers do not live inside one representation. They move among several and use each one for a different purpose.\n",
"\n",
"This is why the notebook keeps translating the same circuit across several forms. The code tells you what was specified. The diagram tells you the structural ordering across wires. The counts tell you what repeated measurement returned. The prose tells you whether you can actually say what the first three views mean. When the same idea survives all four views, it starts becoming stable.\n"
],
"id": "eb133282"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "setup"
},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #6b7280; background:#e5e7eb; color:#111827; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY SETUP</strong> · Difficulty 1/10 · Environment, import, or helper cell required by the notebook.\n",
"</div>\n"
],
"id": "8ae7d676"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"import sys\n",
"\n",
"project_root = Path.cwd().resolve()\n",
"while not (project_root / \"pyproject.toml\").exists():\n",
" if project_root.parent == project_root:\n",
" raise RuntimeError(\"Could not locate the project root from this notebook.\")\n",
" project_root = project_root.parent\n",
"\n",
"src_path = project_root / \"src\"\n",
"if str(src_path) not in sys.path:\n",
" sys.path.insert(0, str(src_path))\n"
],
"id": "d4700ff6"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "setup"
},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #6b7280; background:#e5e7eb; color:#111827; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY SETUP</strong> · Difficulty 1/10 · Environment, import, or helper cell required by the notebook.\n",
"</div>\n"
],
"id": "fa7a20a3"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from quantum_learning import (\n",
" bell_circuit,\n",
" counts_to_probabilities,\n",
" draw_circuit,\n",
" editable_circuit_lab,\n",
" load_curriculum,\n",
" plot_counts,\n",
" quiz_block,\n",
" reflection_box,\n",
" simulate_counts,\n",
" statevector_probabilities,\n",
" step_reference_table,\n",
")\n"
],
"id": "e05a76c6"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
"</div>\n",
"\n",
"## Code-To-Diagram Anchor\n",
"\n",
"The next table pins the anchor circuit to three numbered markers. Read the table before touching the editable cell. The objective is to form a clear translation cycle: code line -> diagram change -> conceptual role. If you cannot move through that cycle without hesitation, you have not yet earned the phrase “I understand the circuit.”\n"
],
"id": "1f282b6b"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY EXERCISE</strong> · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
"</div>\n"
],
"id": "d9ccd8f7"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"step_reference_table([{'marker': '[1]', 'code_focus': 'Prepare qubit 0 with a Hadamard gate.', 'diagram_effect': 'The upper wire branches into a superposition-generating event.', 'why_it_matters': 'This is the first step where the circuit stops behaving like a deterministic classical path.'}, {'marker': '[2]', 'code_focus': 'Use CNOT from qubit 0 to qubit 1.', 'diagram_effect': 'The second wire becomes correlated with the branching created above.', 'why_it_matters': 'This is the moment where local gate syntax becomes shared circuit structure.'}, {'marker': '[3]', 'code_focus': 'Measure both qubits into matching classical bits.', 'diagram_effect': 'The diagram turns a latent correlation into an empirical question.', 'why_it_matters': 'Measurement is not a camera; it is the question being asked of the prepared state.'}])\n"
],
"id": "dde207e8"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
"</div>\n",
"\n",
"## Editable Anchor Circuit\n",
"\n",
"This first editable circuit is intentionally small. The point is not size. The point is control. Change one thing at a time and explain the effect before you click render. If you do not state a prediction first, you lose most of the pedagogical value of the cell.\n"
],
"id": "f5e9b2fc"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY EXERCISE</strong> · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
"</div>\n"
],
"id": "31f5f838"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"editable_code = '\\ncircuit = QuantumCircuit(2, 2)\\n# [1] Prepare the branch point.\\ncircuit.h(0)\\n# [2] Correlate the second qubit with the first.\\ncircuit.cx(0, 1)\\n# [3] Ask the question in the computational basis.\\ncircuit.measure([0, 1], [0, 1])\\n'\n",
"editable_circuit_lab(\n",
" initial_code=editable_code,\n",
" context={\"QuantumCircuit\": __import__(\"qiskit\").QuantumCircuit, \"simulate_counts\": simulate_counts},\n",
" title=\"Bell Anchor Lab\",\n",
" instructions=\"Alter one marker at a time, re-render, and compare your prediction to the updated diagram and counts.\",\n",
")\n"
],
"id": "254cd421"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
"</div>\n",
"\n",
"## Guided Interpretation\n",
"\n",
"Use the anchor circuit to answer a deeper question: what exactly is the relationship between preparation and measurement? The state prepared before measurement is not the same thing as the histogram returned after many shots. The state is a mathematical object that supports many possible questions. The histogram is the answer to one specific question asked many times. This distinction is subtle enough that many beginners gloss over it, but it is foundational. If you do not internalize it now, later work on basis changes, tomography-like reasoning, or noise diagnostics becomes much harder.\n",
"\n",
"The distinction is also why one circuit can give very different empirical stories after a basis rotation. The prepared object may be the same or closely related, but the question has changed. Measurement is therefore part of the design, not an afterthought tacked onto the end of a circuit.\n"
],
"id": "853ea1e5"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY EXERCISE</strong> · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
"</div>\n"
],
"id": "87de2dab"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"anchor = bell_circuit(measure=True)\n",
"counts = simulate_counts(anchor, shots=512)\n",
"probabilities = counts_to_probabilities(counts)\n",
"{\n",
" \"counts\": counts,\n",
" \"probabilities\": probabilities,\n",
"}\n"
],
"id": "adf07a81"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "test"
},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY TEST</strong> · Difficulty 2/10 · Official walkthrough multiple-choice test.\n",
"</div>\n"
],
"id": "4b2f8085"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"quiz_block([{'prompt': 'Which sentence best describes what a circuit diagram is trying to show you?', 'options': ['A list of independent gate icons that happen to share a page', 'A time-ordered argument about how a state is being prepared, transformed, and questioned', 'A decorative rendering of code that mainly helps with presentation'], 'correct_index': 1, 'explanation': 'The course treats a circuit as a time-ordered process whose meaning must be narrated, not just executed.'}, {'prompt': 'Why is the spinning coin analogy useful but limited?', 'options': ['Because it proves that quantum states are really just classical ignorance', 'Because it helps introduce non-binary intuition but cannot capture amplitudes, phase, and measurement structure faithfully', 'Because it is mainly a historical story with no teaching value'], 'correct_index': 1, 'explanation': 'The analogy helps at the doorway, but quantum states require more disciplined language than classical randomness.'}, {'prompt': 'What is the main teaching reason to keep code, circuit graphic, and counts together?', 'options': ['So the notebook feels more interactive', 'So the same idea is forced to survive multiple representations', 'So matplotlib gets used early in the course'], 'correct_index': 1, 'explanation': 'Robust understanding survives translation across representations.'}], heading='Lecture Checkpoint A')\n"
],
"id": "316b806d"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
"</div>\n",
"\n",
"## Measurement As A Question\n",
"\n",
"The phrase “measurement collapses the state” is standard, but on its own it is too coarse to guide design. A better beginner question is: collapse into what, after which transformation, and relative to which basis? If you insert a basis-changing gate immediately before measurement, you have not merely changed notebook syntax. You have changed the operational meaning of the readout. This fact is one of the strongest arguments for teaching circuits through code-diagram-analysis loops rather than through isolated definitions.\n",
"\n",
"In practice, this means you should look at a measurement instruction and ask what precedes it immediately. Are you measuring directly in the computational basis? Have you rotated one wire? Are you asking the same question of both wires or different questions of each? Even in tiny circuits, these distinctions matter. They are the seeds of later professional habits: identifying what the experiment is actually probing, what the output can justify, and where a misleading interpretation would enter.\n"
],
"id": "34e41d16"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
"</div>\n",
"\n",
"## Common Misconceptions To Kill Early\n",
"\n",
"The first misconception is that measurement simply reports a hidden classical value that was there all along. This destroys your ability to reason about basis dependence. The second misconception is that CNOT always means “copy.” In classical logic that shortcut can work; in quantum circuits it becomes misleading as soon as the control wire is not in a classical basis state. The third misconception is that if the histogram looks right, the circuit is therefore understood. Histograms can look plausible for the wrong reason, especially once noise, compilation, or accidental basis changes enter the picture.\n",
"\n",
"The fourth misconception is more emotional than technical: learners think confusion means failure. In reality, confusion becomes useful the moment it is specific. “I do not understand why the inserted Hadamard changed the counts even though the earlier preparation looked the same” is a productive sentence. It contains the exact place where study should deepen. Vague overwhelm does not help. Specific confusion does.\n"
],
"id": "8d36d457"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
"</div>\n",
"\n",
"## What Professional Attention Already Looks Like\n",
"\n",
"It is tempting to imagine that professional attention begins only once the circuits become large. It does not. Professional attention begins the first time you ask which line is carrying the main design burden, what evidence would falsify your story, and how a basis change would alter the meaning of the result. Those are already professional questions. They simply happen to be asked here on a small circuit where every move is still visible enough to discuss.\n",
"\n",
"This is also why the lecture is more text-heavy than a standard tutorial. The text is not padding. It is attention training. It keeps naming the distinctions that matter so your eye can learn to notice them quickly later.\n"
],
"id": "d32b349a"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY EXERCISE</strong> · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
"</div>\n"
],
"id": "caaca043"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"reflection_box(\n",
" \"Write the full story of the Bell anchor circuit in your own words. Do not just name the gates; explain what each stage is doing.\"\n",
")\n"
],
"id": "115c9624"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
"</div>\n",
"\n",
"## Transfer Forward\n",
"\n",
"You might reasonably ask why this lecture is so intense about such a small example. The answer is transfer. Later, when you study oracle circuits, QFT substructures, or hardware-constrained rewrites, you will still need the same reading habits. You will still need to identify branch points, structural relationships across wires, measurement choices, and mismatches between your story and the result. The circuits will grow, but the habits remain.\n",
"\n",
"This is the real professional lesson of the module: the scale of the circuit is not the measure of the sophistication of the thinking. A designer can practice sophisticated attention on a tiny circuit. In fact, that is where the practice should begin, because it is the only place where every move is still visible enough to narrate cleanly.\n",
"\n",
"As you move to the lab, treat the lecture as a set of commitments. You have been told what the mechanism is. The lab will test whether that mechanism survives modification. The problems notebook will test whether the mechanism survives retrieval. The studio will test whether the mechanism survives design pressure. That is the full loop.\n"
],
"id": "8b074443"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "test"
},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY TEST</strong> · Difficulty 2/10 · Official walkthrough multiple-choice test.\n",
"</div>\n"
],
"id": "9b519db1"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"quiz_block([{'prompt': 'In a Bell-style circuit, what conceptual role does the CNOT play after the Hadamard?', 'options': ['It measures the first qubit before the circuit finishes', 'It copies classical information from one wire to another', 'It turns the earlier branching into a structured correlation between wires'], 'correct_index': 2, 'explanation': 'The circuit is not copying a classical bit; it is creating structured correlation from the prepared branch.'}, {'prompt': 'What changes when you insert a basis rotation before measurement?', 'options': ['The underlying prepared state is reinterpreted through a different question', 'Nothing important changes because measurement is always the same', 'The qubit becomes classical before the rotation happens'], 'correct_index': 0, 'explanation': 'Measurement answers a basis-relative question, so basis changes matter profoundly.'}, {'prompt': 'Which habit is most aligned with professional circuit-design growth?', 'options': ['Run first, explain later', 'Predict, run, compare, and revise the story explicitly', 'Memorize gate names until the diagrams feel familiar'], 'correct_index': 1, 'explanation': 'Prediction and explanation are the key habits that distinguish passive exposure from design training.'}], heading='Lecture Checkpoint B')\n"
],
"id": "1d8ed6a0"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY EXERCISE</strong> · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
"</div>\n"
],
"id": "67335971"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"reflection_box(\n",
" \"Name one mistaken sentence about quantum circuits that this lecture forced you to retire, and replace it with a better sentence.\"\n",
")\n"
],
"id": "ed4d31bd"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
"</div>\n",
"\n",
"## Mastery Gate\n",
"\n",
"You have finished the lecture only if you can take a Bell-style circuit, explain it from code to diagram to counts, modify one gate intentionally, and defend what should change before you run the experiment. If that still feels unstable, the correct next move is not to rush ahead. It is to use the lab properly.\n"
],
"id": "86e7fb54"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #2563eb; background:#dbeafe; color:#1e3a8a; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>META READING</strong> · Difficulty 1/10 · Official walkthrough guardrail.\n",
"</div>\n",
"\n",
"<!-- COURSE_NAV_BOTTOM -->\n",
"## What To Open Next\n",
"\n",
"Next notebook: [Principles and Circuit Literacy Lab](lab.ipynb)\n",
"\n",
"Official walkthrough rule: once every mandatory cell above is complete, open the next notebook. Anything below this cell is facultative.\n"
],
"id": "ed9b9fd9"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "facultative_zone",
"ql_track": "meta",
"ql_role": "reading",
"ql_difficulty": 1,
"ql_note": "Optional-zone boundary. The official walkthrough is already complete above."
},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #2563eb; background:#dbeafe; color:#1e3a8a; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>META READING</strong> · Difficulty 1/10 · Optional-zone boundary. The official walkthrough is already complete above.\n",
"</div>\n",
"\n",
"<!-- QL_OPTIONAL_ZONE -->\n",
"## Facultative Extension Zone\n",
"\n",
"You have already completed the mandatory walkthrough for **Principles and Circuit Literacy Lecture**. Everything below is optional. Use it only if you want deeper consolidation or extra transfer work.\n"
],
"id": "c83dfd2b"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "facultative",
"ql_track": "facultative",
"ql_role": "reading",
"ql_difficulty": 4,
"ql_note": "Optional extension reading."
},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #ea580c; background:#ffedd5; color:#9a3412; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>FACULTATIVE READING</strong> · Difficulty 4/10 · Optional extension reading.\n",
"</div>\n",
"\n",
"## Facultative Extension Reading\n",
"\n",
"Treat **Principles and Circuit Literacy Lecture** as a transfer checkpoint. Ask which mechanism from the mandatory cells would still matter if one qubit, one basis choice, or one comparison target changed. This optional reading cell exists to stretch the idea without changing the official route.\n"
],
"id": "7d23401a"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "facultative",
"ql_role": "test"
},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #ea580c; background:#ffedd5; color:#9a3412; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>FACULTATIVE TEST</strong> · Difficulty 5/10 · Optional multiple-choice extension.\n",
"</div>\n"
],
"id": "a4d26d74"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ql_injected": "facultative",
"ql_track": "facultative",
"ql_role": "test",
"ql_difficulty": 5,
"ql_note": "Optional multiple-choice extension.",
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"quiz_block([{'prompt': 'What should stay stable if you transfer the main mechanism from Principles and Circuit Literacy Lecture into a new small circuit?', 'options': ['The causal idea being tested', 'The exact notebook filename', 'The original counts histogram regardless of the change'], 'correct_index': 0, 'explanation': 'Transfer begins by preserving the mechanism, not the surface form.'}, {'prompt': 'What is the point of a facultative lecture extension?', 'options': ['To deepen transfer after the mandatory path is already complete', 'To replace the mandatory cells', 'To skip the lab and studio'], 'correct_index': 0, 'explanation': 'Facultative cells extend; they do not redefine the route.'}], heading='Facultative Extension Test')\n"
],
"id": "d55b8c7a"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "facultative",
"ql_role": "exercise"
},
"source": [
"<!-- QL_BADGE -->\n",
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #ea580c; background:#ffedd5; color:#9a3412; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
"<strong>FACULTATIVE EXERCISE</strong> · Difficulty 6/10 · Optional written exercise.\n",
"</div>\n"
],
"id": "f31d58d6"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ql_injected": "facultative",
"ql_track": "facultative",
"ql_role": "exercise",
"ql_difficulty": 6,
"ql_note": "Optional written exercise.",
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"reflection_box('State one mechanism from Principles and Circuit Literacy Lecture that you could now transfer to a slightly different circuit, and name the first thing you would hold fixed while testing that transfer.')\n"
],
"id": "ec5db2b5"
}
],
"metadata": {
"kernelspec": {
"display_name": "QuantumLearning (.venv)",
"language": "python",
"name": "quantum-learning"
},
"language_info": {
"name": "python",
"version": "3.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}