NTT-learning/notebooks/foundations/01_convolution_to_toy_ntt/problems.ipynb

130 lines
5 KiB
Text

{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"pedagogy": {
"role": "meta",
"difficulty": 1,
"kind": "orientation",
"title": "Problem Set Goals"
}
},
"source": "## META | difficulty 1 | Problem Set Goals\n\nUse this notebook to check retrieval, not to discover the topic for the first time.\nIf the questions feel opaque, return to the lecture and lab first.\n"
},
{
"cell_type": "markdown",
"metadata": {
"pedagogy": {
"role": "mandatory",
"difficulty": 2,
"kind": "quiz",
"title": "Multiple-Choice Retrieval"
}
},
"source": "## MANDATORY | difficulty 2 | Multiple-Choice Retrieval\n\nChoose one answer for each:\n\n1. Negacyclic reduction mainly changes:\n A. coefficient labels only\n B. wraparound terms by folding them back with sign changes\n C. the modulus but not the polynomial ring\n\n2. The toy NTT is introduced early because it:\n A. already matches Kyber implementation details exactly\n B. removes the need to inspect arrays\n C. gives a small, reversible transform that can be inspected directly\n\n3. A butterfly stage is best thought of as:\n A. a local rewrite over paired entries\n B. a proof that convolution is impossible\n C. a random permutation with no arithmetic structure\n"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pedagogy": {
"role": "mandatory",
"difficulty": 2,
"kind": "quiz",
"title": "Answer Key"
}
},
"outputs": [],
"source": "# MANDATORY | difficulty 2 | Answer Key\n\nanswers = {\n 1: \"B\",\n 2: \"C\",\n 3: \"A\",\n}\n\nprint(answers)\n"
},
{
"cell_type": "markdown",
"metadata": {
"pedagogy": {
"role": "mandatory",
"difficulty": 2,
"kind": "reflection",
"title": "Written Reflection"
}
},
"source": "## MANDATORY | difficulty 2 | Written Reflection\n\nReflection prompt:\n\n- In one paragraph, separate the algebraic purpose of the NTT from the local butterfly dataflow.\n- In one sentence, explain why the course postpones Kyber-specific indexing.\n"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pedagogy": {
"role": "mandatory",
"difficulty": 2,
"kind": "exercise",
"title": "Verify A Round Trip"
}
},
"outputs": [],
"source": "# MANDATORY | difficulty 2 | Verify A Round Trip\n\nfrom ntt_learning.toy_ntt import find_primitive_root, forward_ntt, inverse_ntt\n\nsignal = [3, 1, 4, 1]\nmodulus = 17\nomega = find_primitive_root(order=4, modulus=modulus)\nrecovered = inverse_ntt(forward_ntt(signal, modulus=modulus, omega=omega), modulus=modulus, omega=omega)\n\nassert recovered == signal\nprint(\"round-trip verified:\", recovered)\n"
},
{
"cell_type": "markdown",
"metadata": {
"pedagogy": {
"role": "facultative",
"difficulty": 4,
"kind": "exploration",
"title": "Optional Challenge"
}
},
"source": "## FACULTATIVE | difficulty 4 | Optional Challenge\n\nTry replacing the signal with your own four coefficients and predict the forward spectrum before running the next cell.\n"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pedagogy": {
"role": "facultative",
"difficulty": 4,
"kind": "exploration",
"title": "Explore Another Signal"
}
},
"outputs": [],
"source": "# FACULTATIVE | difficulty 4 | Explore Another Signal\n\nfrom ntt_learning.toy_ntt import find_primitive_root, forward_ntt\n\nsignal = [6, 0, 5, 2]\nmodulus = 17\nomega = find_primitive_root(order=4, modulus=modulus)\n\nprint(\"spectrum:\", forward_ntt(signal, modulus=modulus, omega=omega))\n"
},
{
"cell_type": "markdown",
"metadata": {
"pedagogy": {
"role": "meta",
"difficulty": 1,
"kind": "handoff",
"title": "Next Notebook"
}
},
"source": "## META | difficulty 1 | Next Notebook\n\nNext notebook: `studio.ipynb`\n"
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
},
"ntt_learning": {
"title": "Problems: Convolution To Toy NTT",
"contract_version": "0.1",
"sequence": [
"notebooks/START_HERE.ipynb",
"notebooks/COURSE_BLUEPRINT.ipynb",
"notebooks/foundations/01_convolution_to_toy_ntt/lecture.ipynb",
"notebooks/foundations/01_convolution_to_toy_ntt/lab.ipynb",
"notebooks/foundations/01_convolution_to_toy_ntt/problems.ipynb",
"notebooks/foundations/01_convolution_to_toy_ntt/studio.ipynb"
]
}
},
"nbformat": 4,
"nbformat_minor": 5
}