@louisultra/dsh-verymath 0.0.0-stage → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/CHANGELOG.md +133 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE.md +35 -0
  4. package/README.md +108 -2
  5. package/README_EN.md +105 -0
  6. package/UPSTREAM.json +106 -0
  7. package/cordis.patch.yml +12 -0
  8. package/docs/capability-examples.md +581 -0
  9. package/docs/examples/README.md +32 -0
  10. package/docs/examples/bad_scan.md +10 -0
  11. package/docs/examples/broken-proof.lean +9 -0
  12. package/docs/examples/claims.md +7 -0
  13. package/docs/examples/knapsack.json +10 -0
  14. package/docs/examples/matrix.json +1 -0
  15. package/docs/examples/points.csv +21 -0
  16. package/docs/examples/qp.json +8 -0
  17. package/docs/examples/research-ws/project/GOALS.yaml +4 -0
  18. package/docs/examples/research-ws/workstreams/ws-lsa/report.md +13 -0
  19. package/docs/examples/research-ws/workstreams/ws-lsa/reviews/r1.json +1 -0
  20. package/docs/examples/research-ws/workstreams/ws-lsa/status.yaml +1 -0
  21. package/docs/examples/source.csv +4 -0
  22. package/lib/core/error.d.ts +20 -0
  23. package/lib/core/error.js +25 -0
  24. package/lib/core/gates.d.ts +42 -0
  25. package/lib/core/gates.js +217 -0
  26. package/lib/core/glossary.d.ts +101 -0
  27. package/lib/core/glossary.js +243 -0
  28. package/lib/core/graph.d.ts +118 -0
  29. package/lib/core/graph.js +460 -0
  30. package/lib/core/index.d.ts +120 -0
  31. package/lib/core/index.js +197 -0
  32. package/lib/core/paper.d.ts +163 -0
  33. package/lib/core/paper.js +73 -0
  34. package/lib/core/paths.d.ts +2 -0
  35. package/lib/core/paths.js +12 -0
  36. package/lib/core/sage.d.ts +61 -0
  37. package/lib/core/sage.js +212 -0
  38. package/lib/core/skills.d.ts +11 -0
  39. package/lib/core/skills.js +110 -0
  40. package/lib/tool/index.d.ts +21 -0
  41. package/lib/tool/index.js +1144 -0
  42. package/package.json +92 -4
  43. package/skills/after-ocr/SKILL.md +123 -0
  44. package/skills/after-ocr/references/audit-schema.md +94 -0
  45. package/skills/after-ocr/references/error-taxonomy.md +179 -0
  46. package/skills/after-ocr/scripts/merge_audit_logs.py +329 -0
  47. package/skills/after-ocr/scripts/scan_markdown_ocr.py +350 -0
  48. package/skills/after-ocr/tests/test_scripts.py +84 -0
  49. package/skills/discover-math-problems/SKILL.md +115 -0
  50. package/skills/discover-math-problems/references/artifact-contract.md +93 -0
  51. package/skills/discover-math-problems/references/autonomous-research-protocol.md +86 -0
  52. package/skills/discover-math-problems/references/conjecture-generation-protocol.md +63 -0
  53. package/skills/discover-math-problems/references/extremal-graph-variants.md +53 -0
  54. package/skills/graph-theory-paper-reading/SKILL.md +600 -0
  55. package/skills/invariant-computation/SKILL.md +169 -0
  56. package/skills/invariant-computation/examples/invariant_summary.example.json +51 -0
  57. package/skills/invariant-computation/manifest.yaml +46 -0
  58. package/skills/invariant-computation/references/INDEX.md +20 -0
  59. package/skills/invariant-computation/references/failure_modes.md +40 -0
  60. package/skills/invariant-computation/references/method_route_map.md +177 -0
  61. package/skills/invariant-computation/references/source_notes.md +19 -0
  62. package/skills/invariant-computation/references/tool_catalog.md +65 -0
  63. package/skills/invariant-computation/references/validation_checks.md +52 -0
  64. package/skills/invariant-computation/schema/invariant_summary.schema.json +260 -0
  65. package/skills/lean-formalization/SKILL.md +111 -0
  66. package/skills/lean-formalization/lean-runtime/config/env.example +5 -0
  67. package/skills/lean-formalization/lean-runtime/config/lean_agent.example.toml +28 -0
  68. package/skills/lean-formalization/lean-runtime/config/numina_runtime.example.toml +12 -0
  69. package/skills/lean-formalization/lean-runtime/examples/smoke/LocalLeanSmoke.lean +7 -0
  70. package/skills/lean-formalization/lean-runtime/prompts/complete_sorries.md +3 -0
  71. package/skills/lean-formalization/lean-runtime/prompts/formalize_statement.md +3 -0
  72. package/skills/lean-formalization/lean-runtime/prompts/prove_theorem.md +3 -0
  73. package/skills/lean-formalization/lean-runtime/prompts/repair_lean_file.md +3 -0
  74. package/skills/lean-formalization/lean-runtime/references/backend_adapter_checklist.md +36 -0
  75. package/skills/lean-formalization/lean-runtime/references/direct_lean_workflow.md +48 -0
  76. package/skills/lean-formalization/lean-runtime/references/failure_taxonomy.md +17 -0
  77. package/skills/lean-formalization/lean-runtime/references/interactive_orchestration.md +83 -0
  78. package/skills/lean-formalization/lean-runtime/references/lean_agent_capability_map.md +116 -0
  79. package/skills/lean-formalization/lean-runtime/references/lean_lsp_mcp_adapter.md +219 -0
  80. package/skills/lean-formalization/lean-runtime/references/lean_runtime_configuration.md +92 -0
  81. package/skills/lean-formalization/lean-runtime/references/numina_reverse_analysis.md +80 -0
  82. package/skills/lean-formalization/lean-runtime/references/numina_runtime.md +41 -0
  83. package/skills/lean-formalization/lean-runtime/references/numina_subagent_troubleshooting.md +77 -0
  84. package/skills/lean-formalization/lean-runtime/references/review_checklist.md +10 -0
  85. package/skills/lean-formalization/lean-runtime/references/specialist_agent_patterns.md +65 -0
  86. package/skills/lean-formalization/lean-runtime/schemas/config.schema.json +12 -0
  87. package/skills/lean-formalization/lean-runtime/schemas/result.schema.json +33 -0
  88. package/skills/lean-formalization/lean-runtime/schemas/task.schema.json +30 -0
  89. package/skills/lean-formalization/lean-runtime/scripts/ai4m_lean.py +222 -0
  90. package/skills/lean-formalization/lean-runtime/scripts/check_lean_project.py +134 -0
  91. package/skills/lean-formalization/lean-runtime/scripts/common.py +296 -0
  92. package/skills/lean-formalization/lean-runtime/scripts/configure_lean.py +222 -0
  93. package/skills/lean-formalization/lean-runtime/scripts/detect_sorry.py +49 -0
  94. package/skills/lean-formalization/lean-runtime/scripts/direct_task.py +100 -0
  95. package/skills/lean-formalization/lean-runtime/scripts/extract_minimal_failure.py +74 -0
  96. package/skills/lean-formalization/lean-runtime/scripts/numina_runtime.py +414 -0
  97. package/skills/lean-formalization/lean-runtime/scripts/smoke_test.py +75 -0
  98. package/skills/lean-formalization/lean-runtime/scripts/tool_status.py +79 -0
  99. package/skills/lean-formalization/lean-runtime/scripts/validate_patch.py +81 -0
  100. package/skills/lean-formalization/lean-runtime/scripts/verify_delivery.py +484 -0
  101. package/skills/lean-formalization/lean-runtime/tests/fixtures/after_bad.lean +4 -0
  102. package/skills/lean-formalization/lean-runtime/tests/fixtures/after_statement_changed.lean +4 -0
  103. package/skills/lean-formalization/lean-runtime/tests/fixtures/before.lean +4 -0
  104. package/skills/lean-formalization/lean-runtime/tests/fixtures/failure.lean +7 -0
  105. package/skills/lean-formalization/lean-runtime/tests/test_check_lean_project.py +59 -0
  106. package/skills/lean-formalization/lean-runtime/tests/test_cli.py +377 -0
  107. package/skills/lean-formalization/lean-runtime/tests/test_common_config.py +84 -0
  108. package/skills/lean-formalization/lean-runtime/tests/test_configure_lean.py +138 -0
  109. package/skills/lean-formalization/lean-runtime/tests/test_detect_sorry.py +24 -0
  110. package/skills/lean-formalization/lean-runtime/tests/test_direct_task.py +69 -0
  111. package/skills/lean-formalization/lean-runtime/tests/test_numina_runtime.py +168 -0
  112. package/skills/lean-formalization/lean-runtime/tests/test_validate_patch.py +29 -0
  113. package/skills/lean-setup/SKILL.md +99 -0
  114. package/skills/least-squares/README.md +85 -0
  115. package/skills/least-squares/SKILL.md +613 -0
  116. package/skills/least-squares/examples.md +380 -0
  117. package/skills/math-beamer/SKILL.md +325 -0
  118. package/skills/math-beamer/references/build-and-layout-audit.md +63 -0
  119. package/skills/math-beamer/references/math-domain-patterns.md +56 -0
  120. package/skills/math-beamer/references/template-policy.md +43 -0
  121. package/skills/math-beamer/references/template-source-index.md +51 -0
  122. package/skills/math-beamer/templates/catalog.yaml +235 -0
  123. package/skills/math-beamer/templates/packs/algebra-number-theory-talk/main.tex +45 -0
  124. package/skills/math-beamer/templates/packs/algebra-number-theory-talk/template.yaml +9 -0
  125. package/skills/math-beamer/templates/packs/algorithm-talk/main.tex +43 -0
  126. package/skills/math-beamer/templates/packs/algorithm-talk/template.yaml +9 -0
  127. package/skills/math-beamer/templates/packs/analysis-core-talk/main.tex +49 -0
  128. package/skills/math-beamer/templates/packs/analysis-core-talk/template.yaml +19 -0
  129. package/skills/math-beamer/templates/packs/backup-heavy-talk/main.tex +40 -0
  130. package/skills/math-beamer/templates/packs/backup-heavy-talk/template.yaml +9 -0
  131. package/skills/math-beamer/templates/packs/beamerposter-a0/main.tex +45 -0
  132. package/skills/math-beamer/templates/packs/beamerposter-a0/template.yaml +12 -0
  133. package/skills/math-beamer/templates/packs/combinatorics-graph-talk/main.tex +53 -0
  134. package/skills/math-beamer/templates/packs/combinatorics-graph-talk/template.yaml +18 -0
  135. package/skills/math-beamer/templates/packs/control-systems-talk/main.tex +51 -0
  136. package/skills/math-beamer/templates/packs/control-systems-talk/template.yaml +18 -0
  137. package/skills/math-beamer/templates/packs/course-lecture-zh/main.tex +43 -0
  138. package/skills/math-beamer/templates/packs/course-lecture-zh/template.yaml +9 -0
  139. package/skills/math-beamer/templates/packs/data-experiment-results/main.tex +45 -0
  140. package/skills/math-beamer/templates/packs/data-experiment-results/template.yaml +9 -0
  141. package/skills/math-beamer/templates/packs/dynamical-systems-talk/main.tex +42 -0
  142. package/skills/math-beamer/templates/packs/dynamical-systems-talk/template.yaml +9 -0
  143. package/skills/math-beamer/templates/packs/geometry-topology-talk/main.tex +43 -0
  144. package/skills/math-beamer/templates/packs/geometry-topology-talk/template.yaml +9 -0
  145. package/skills/math-beamer/templates/packs/information-coding-crypto-talk/main.tex +49 -0
  146. package/skills/math-beamer/templates/packs/information-coding-crypto-talk/template.yaml +18 -0
  147. package/skills/math-beamer/templates/packs/logic-foundations-category-talk/main.tex +51 -0
  148. package/skills/math-beamer/templates/packs/logic-foundations-category-talk/template.yaml +18 -0
  149. package/skills/math-beamer/templates/packs/numerical-analysis-talk/main.tex +51 -0
  150. package/skills/math-beamer/templates/packs/numerical-analysis-talk/template.yaml +9 -0
  151. package/skills/math-beamer/templates/packs/optimization-talk/main.tex +58 -0
  152. package/skills/math-beamer/templates/packs/optimization-talk/template.yaml +9 -0
  153. package/skills/math-beamer/templates/packs/pde-analysis-talk/main.tex +49 -0
  154. package/skills/math-beamer/templates/packs/pde-analysis-talk/template.yaml +9 -0
  155. package/skills/math-beamer/templates/packs/probability-statistics-talk/main.tex +52 -0
  156. package/skills/math-beamer/templates/packs/probability-statistics-talk/template.yaml +9 -0
  157. package/skills/math-beamer/templates/packs/reading-group-paper/main.tex +46 -0
  158. package/skills/math-beamer/templates/packs/reading-group-paper/template.yaml +9 -0
  159. package/skills/math-beamer/templates/packs/seminar-minimal-en/main.tex +60 -0
  160. package/skills/math-beamer/templates/packs/seminar-minimal-en/template.yaml +13 -0
  161. package/skills/math-beamer/templates/packs/seminar-minimal-zh/main.tex +60 -0
  162. package/skills/math-beamer/templates/packs/seminar-minimal-zh/template.yaml +13 -0
  163. package/skills/math-beamer/templates/packs/theorem-proof-talk/main.tex +60 -0
  164. package/skills/math-beamer/templates/packs/theorem-proof-talk/template.yaml +9 -0
  165. package/skills/math-beamer/templates/packs/thesis-defense/main.tex +42 -0
  166. package/skills/math-beamer/templates/packs/thesis-defense/template.yaml +9 -0
  167. package/skills/math-beamer/templates/packs/workshop-tutorial/main.tex +32 -0
  168. package/skills/math-beamer/templates/packs/workshop-tutorial/template.yaml +9 -0
  169. package/skills/math-beamer/templates/preview-gallery.md +32 -0
  170. package/skills/math-beamer/templates/previews/algebra-number-theory-talk-content.png +0 -0
  171. package/skills/math-beamer/templates/previews/algebra-number-theory-talk-cover.png +0 -0
  172. package/skills/math-beamer/templates/previews/algorithm-talk-content.png +0 -0
  173. package/skills/math-beamer/templates/previews/algorithm-talk-cover.png +0 -0
  174. package/skills/math-beamer/templates/previews/analysis-core-talk-content.png +0 -0
  175. package/skills/math-beamer/templates/previews/analysis-core-talk-cover.png +0 -0
  176. package/skills/math-beamer/templates/previews/backup-heavy-talk-content.png +0 -0
  177. package/skills/math-beamer/templates/previews/backup-heavy-talk-cover.png +0 -0
  178. package/skills/math-beamer/templates/previews/beamerposter-a0-content.png +0 -0
  179. package/skills/math-beamer/templates/previews/beamerposter-a0-cover.png +0 -0
  180. package/skills/math-beamer/templates/previews/combinatorics-graph-talk-content.png +0 -0
  181. package/skills/math-beamer/templates/previews/combinatorics-graph-talk-cover.png +0 -0
  182. package/skills/math-beamer/templates/previews/control-systems-talk-content.png +0 -0
  183. package/skills/math-beamer/templates/previews/control-systems-talk-cover.png +0 -0
  184. package/skills/math-beamer/templates/previews/course-lecture-zh-content.png +0 -0
  185. package/skills/math-beamer/templates/previews/course-lecture-zh-cover.png +0 -0
  186. package/skills/math-beamer/templates/previews/data-experiment-results-content.png +0 -0
  187. package/skills/math-beamer/templates/previews/data-experiment-results-cover.png +0 -0
  188. package/skills/math-beamer/templates/previews/dynamical-systems-talk-content.png +0 -0
  189. package/skills/math-beamer/templates/previews/dynamical-systems-talk-cover.png +0 -0
  190. package/skills/math-beamer/templates/previews/geometry-topology-talk-content.png +0 -0
  191. package/skills/math-beamer/templates/previews/geometry-topology-talk-cover.png +0 -0
  192. package/skills/math-beamer/templates/previews/information-coding-crypto-talk-content.png +0 -0
  193. package/skills/math-beamer/templates/previews/information-coding-crypto-talk-cover.png +0 -0
  194. package/skills/math-beamer/templates/previews/logic-foundations-category-talk-content.png +0 -0
  195. package/skills/math-beamer/templates/previews/logic-foundations-category-talk-cover.png +0 -0
  196. package/skills/math-beamer/templates/previews/numerical-analysis-talk-content.png +0 -0
  197. package/skills/math-beamer/templates/previews/numerical-analysis-talk-cover.png +0 -0
  198. package/skills/math-beamer/templates/previews/optimization-talk-content.png +0 -0
  199. package/skills/math-beamer/templates/previews/optimization-talk-cover.png +0 -0
  200. package/skills/math-beamer/templates/previews/pde-analysis-talk-content.png +0 -0
  201. package/skills/math-beamer/templates/previews/pde-analysis-talk-cover.png +0 -0
  202. package/skills/math-beamer/templates/previews/probability-statistics-talk-content.png +0 -0
  203. package/skills/math-beamer/templates/previews/probability-statistics-talk-cover.png +0 -0
  204. package/skills/math-beamer/templates/previews/reading-group-paper-content.png +0 -0
  205. package/skills/math-beamer/templates/previews/reading-group-paper-cover.png +0 -0
  206. package/skills/math-beamer/templates/previews/seminar-minimal-en-content.png +0 -0
  207. package/skills/math-beamer/templates/previews/seminar-minimal-en-cover.png +0 -0
  208. package/skills/math-beamer/templates/previews/seminar-minimal-zh-content.png +0 -0
  209. package/skills/math-beamer/templates/previews/seminar-minimal-zh-cover.png +0 -0
  210. package/skills/math-beamer/templates/previews/theorem-proof-talk-content.png +0 -0
  211. package/skills/math-beamer/templates/previews/theorem-proof-talk-cover.png +0 -0
  212. package/skills/math-beamer/templates/previews/thesis-defense-content.png +0 -0
  213. package/skills/math-beamer/templates/previews/thesis-defense-cover.png +0 -0
  214. package/skills/math-beamer/templates/previews/workshop-tutorial-content.png +0 -0
  215. package/skills/math-beamer/templates/previews/workshop-tutorial-cover.png +0 -0
  216. package/skills/math-beamer/templates/review-report.md +54 -0
  217. package/skills/math-beamer/templates/slide-source-ledger.md +22 -0
  218. package/skills/math-beamer/templates/source-packet.md +50 -0
  219. package/skills/math-glossary/SKILL.md +347 -0
  220. package/skills/math-glossary/references/glossary-schema.md +71 -0
  221. package/skills/math-glossary/references/glossary-usage-guide.md +176 -0
  222. package/skills/math-glossary/references/glossary-web-template.md +127 -0
  223. package/skills/math-glossary/references/glossary.schema.json +76 -0
  224. package/skills/math-glossary/references/user-manual.md +435 -0
  225. package/skills/math-glossary/requirements-ai.txt +3 -0
  226. package/skills/math-glossary/requirements.txt +3 -0
  227. package/skills/math-glossary/scripts/glossary_backup.py +42 -0
  228. package/skills/math-glossary/scripts/glossary_build.py +467 -0
  229. package/skills/math-glossary/scripts/glossary_enrich_examples.py +283 -0
  230. package/skills/math-glossary/scripts/glossary_export.py +333 -0
  231. package/skills/math-glossary/scripts/glossary_web.py +1265 -0
  232. package/skills/math-paper-reading/README.md +163 -0
  233. package/skills/math-paper-reading/SKILL.md +48 -0
  234. package/skills/math-paper-reading/agent_router.md +36 -0
  235. package/skills/math-paper-reading/references/proof_pattern_taxonomy.md +123 -0
  236. package/skills/math-paper-reading/references/quality_rubric.md +36 -0
  237. package/skills/math-paper-reading/skill_base.md +627 -0
  238. package/skills/math-paper-reading/skill_literature_search.md +866 -0
  239. package/skills/math-paper-reading/skill_paper_deep_read.md +1024 -0
  240. package/skills/math-paper-reading/skill_pathway_proof.md +718 -0
  241. package/skills/math-paper-reading/skill_reference_manager.md +746 -0
  242. package/skills/matlab-runner/SKILL.md +217 -0
  243. package/skills/matlab-runner/examples/README.md +33 -0
  244. package/skills/matlab-runner/examples/matrix_report.m +28 -0
  245. package/skills/matlab-runner/examples/plot_damped_sine.m +64 -0
  246. package/skills/matlab-runner/examples/test_vector_norm.m +12 -0
  247. package/skills/matlab-runner/references/client-setup.md +24 -0
  248. package/skills/matlab-runner/references/file-session-safety.md +86 -0
  249. package/skills/matlab-runner/references/numerical-safety.md +126 -0
  250. package/skills/matlab-runner/references/resource-safety.md +125 -0
  251. package/skills/mixed-integer-programming/SKILL.md +119 -0
  252. package/skills/mixed-integer-programming/lp-examples.md +251 -0
  253. package/skills/mixed-integer-programming/mip-examples-verified.md +118 -0
  254. package/skills/open-problem-research-pipeline/SKILL.md +76 -0
  255. package/skills/open-problem-research-pipeline/skill_literature_analysis.md +201 -0
  256. package/skills/open-problem-research-pipeline/skill_literature_proof_framework.md +206 -0
  257. package/skills/open-problem-research-pipeline/skill_literature_search.md +172 -0
  258. package/skills/open-problem-research-pipeline/skill_qskill.md +177 -0
  259. package/skills/osqp-solver/SKILL.md +245 -0
  260. package/skills/osqp-solver/references/citation.md +25 -0
  261. package/skills/osqp-solver/references/dual-infeasible-example.json +14 -0
  262. package/skills/osqp-solver/references/feasible-example.json +21 -0
  263. package/skills/osqp-solver/references/primal-infeasible-example.json +17 -0
  264. package/skills/osqp-solver/references/python-api.md +95 -0
  265. package/skills/osqp-solver/references/verification.md +94 -0
  266. package/skills/osqp-solver/scripts/check_osqp_environment.py +120 -0
  267. package/skills/osqp-solver/scripts/solve_qp.py +943 -0
  268. package/skills/paper-writing/SKILL.md +115 -0
  269. package/skills/paper-writing/skill_claim_evidence_ledger.md +55 -0
  270. package/skills/paper-writing/skill_formula_environment_and_readability.md +41 -0
  271. package/skills/paper-writing/skill_latex_build_and_layout_audit.md +73 -0
  272. package/skills/paper-writing/skill_notation_and_variable_consistency.md +42 -0
  273. package/skills/paper-writing/skill_paper_skeleton_and_logical_architecture.md +54 -0
  274. package/skills/paper-writing/skill_proof_obligation_and_assumption_audit.md +57 -0
  275. package/skills/paper-writing/templates/claim-evidence-ledger.md +23 -0
  276. package/skills/paper-writing/templates/proof-obligation-ledger.md +22 -0
  277. package/skills/paper-writing/templates/rapid-prototype-paper-skeleton.md +46 -0
  278. package/skills/paper-writing/templates/source-packet.md +37 -0
  279. package/skills/paper-writing/templates/submission-readiness.md +41 -0
  280. package/skills/proof-blueprint-review/SKILL.md +129 -0
  281. package/skills/proof-blueprint-review/references/agent-mediated-proof-protocol.md +57 -0
  282. package/skills/proof-blueprint-review/references/generation-agent.md +45 -0
  283. package/skills/proof-blueprint-review/references/proof-acceptance-contract.md +41 -0
  284. package/skills/proof-blueprint-review/references/verification-agent.md +37 -0
@@ -0,0 +1,380 @@
1
+ # 最小二乘参考示例
2
+
3
+ <!--
4
+ 作者:李爽夕
5
+ 数据引用:部分示例数据来自 NIST Statistical Reference Datasets (StRD)
6
+ URL: https://itl.nist.gov/div898/strd/nls/nls_main.shtml
7
+ 美国政府公共领域数据,可自由使用,需注明来源。
8
+ -->
9
+
10
+ > 模型:deepseek-v4-pro
11
+
12
+ ---
13
+
14
+ ## 示例 1:线性拟合
15
+
16
+ ### 问题描述
17
+
18
+ 对 10 组观测数据 (x, y) 进行一元线性回归 y = a*x + b。
19
+
20
+ ```
21
+ x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
22
+ y = [1.2, 2.1, 2.9, 4.0, 5.1, 5.8, 7.0, 8.2, 8.9, 10.1]
23
+ ```
24
+
25
+ ### 代码实现
26
+
27
+ ```python
28
+ import numpy as np
29
+
30
+ x = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
31
+ y = np.array([1.2, 2.1, 2.9, 4.0, 5.1, 5.8, 7.0, 8.2, 8.9, 10.1])
32
+
33
+ X = np.column_stack([np.ones_like(x), x])
34
+ beta, residuals, rank, s = np.linalg.lstsq(X, y, rcond=None)
35
+ b, a = beta
36
+
37
+ y_pred = a * x + b
38
+ r2 = 1 - np.sum((y - y_pred)**2) / np.sum((y - np.mean(y))**2)
39
+
40
+ print(f"y = {a:.3f}x + {b:.3f}, R² = {r2:.4f}")
41
+ ```
42
+
43
+ ---
44
+
45
+ ## 示例 2:多项式拟合
46
+
47
+ ### 问题描述
48
+
49
+ 11 组数据呈明显二次曲线趋势,用 2 阶多项式 y = c0 + c1*x + c2*x^2 拟合。
50
+
51
+ ```
52
+ x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
53
+ y = [1.0, 0.8, 1.5, 2.3, 3.8, 5.0, 7.5, 10.1, 13.0, 16.5, 20.2]
54
+ ```
55
+
56
+ ### 代码实现
57
+
58
+ ```python
59
+ import numpy as np
60
+
61
+ x = np.linspace(0, 10, 11)
62
+ y = np.array([1.0, 0.8, 1.5, 2.3, 3.8, 5.0, 7.5, 10.1, 13.0, 16.5, 20.2])
63
+
64
+ coeffs = np.polyfit(x, y, deg=2)
65
+ p = np.poly1d(coeffs)
66
+ y_pred = p(x)
67
+
68
+ r2 = 1 - np.sum((y - y_pred)**2) / np.sum((y - np.mean(y))**2)
69
+ print(f"方程: y = {coeffs[0]:.3f}x^2 + {coeffs[1]:.3f}x + {coeffs[2]:.3f}")
70
+ print(f"R² = {r2:.4f}")
71
+ ```
72
+
73
+ ---
74
+
75
+ ## 示例 3:指数衰减拟合
76
+
77
+ ### 问题描述
78
+
79
+ 11 组测量数据呈现指数衰减特征,用模型 y = a*exp(-b*x) + c 拟合。
80
+
81
+ ```
82
+ x = [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0]
83
+ y = [5.0, 3.2, 2.1, 1.4, 0.9, 0.6, 0.4, 0.3, 0.2, 0.1, 0.1]
84
+ ```
85
+
86
+ ### 代码实现
87
+
88
+ ```python
89
+ import numpy as np
90
+ from scipy.optimize import curve_fit
91
+
92
+ x = np.array([0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0])
93
+ y = np.array([5.0, 3.2, 2.1, 1.4, 0.9, 0.6, 0.4, 0.3, 0.2, 0.1, 0.1])
94
+
95
+ def exp_decay(x, a, b, c):
96
+ return a * np.exp(-b * x) + c
97
+
98
+ popt, pcov = curve_fit(exp_decay, x, y, p0=[4, 1, 0])
99
+ perr = np.sqrt(np.diag(pcov))
100
+
101
+ y_pred = exp_decay(x, *popt)
102
+ r2 = 1 - np.sum((y - y_pred)**2) / np.sum((y - np.mean(y))**2)
103
+
104
+ print(f"a = {popt[0]:.3f} ± {perr[0]:.3f}")
105
+ print(f"b = {popt[1]:.3f} ± {perr[1]:.3f}")
106
+ print(f"c = {popt[2]:.3f} ± {perr[2]:.3f}")
107
+ print(f"R² = {r2:.4f}")
108
+ ```
109
+
110
+ ---
111
+
112
+ ## 示例 4:Ridge 正则化回归
113
+
114
+ ### 问题描述
115
+
116
+ 100 个样本、10 个特征,其中特征 2 与特征 1 高度相关(r~0.8),存在多重共线性。用 Ridge 正则化 (alpha=1.0) 收缩系数,对比 OLS。
117
+
118
+ ### 代码实现
119
+
120
+ ```python
121
+ import numpy as np
122
+ from sklearn.linear_model import Ridge, LinearRegression
123
+ from sklearn.preprocessing import StandardScaler
124
+
125
+ np.random.seed(42)
126
+ n, p = 100, 10
127
+ X = np.random.randn(n, p)
128
+ X[:, 2] = 0.8 * X[:, 1] + 0.2 * np.random.randn(n)
129
+
130
+ true_coef = np.array([1.5, -2.0, 0, 0, 3.0, 0, 0, 0.5, 0, 0])
131
+ y = X @ true_coef + 0.5 * np.random.randn(n)
132
+
133
+ scaler = StandardScaler()
134
+ Xs = scaler.fit_transform(X)
135
+
136
+ ols = LinearRegression().fit(Xs, y)
137
+ ridge = Ridge(alpha=1.0).fit(Xs, y)
138
+
139
+ for i in range(p):
140
+ print(f"x{i}: true={true_coef[i]:+.1f}, "
141
+ f"OLS={ols.coef_[i]:+.3f}, Ridge={ridge.coef_[i]:+.3f}")
142
+ print(f"OLS系数范数: {np.linalg.norm(ols.coef_):.3f}")
143
+ print(f"Ridge系数范数: {np.linalg.norm(ridge.coef_):.3f}")
144
+ ```
145
+
146
+ ---
147
+
148
+ ## 示例 5:加权最小二乘
149
+
150
+ ### 问题描述
151
+
152
+ 20 组异方差数据:噪声标准差随 x 线性增大(0.5 到 2.0)。用权重 w=1/方差 进行加权最小二乘拟合 y = a*x + b,对比 OLS。
153
+
154
+ ### 代码实现
155
+
156
+ ```python
157
+ import numpy as np
158
+
159
+ np.random.seed(42)
160
+ x = np.linspace(0, 10, 20)
161
+ true_a, true_b = 2.0, 1.0
162
+ noise_std = 0.5 * (1 + 0.3 * x)
163
+ y = true_a * x + true_b + np.random.randn(len(x)) * noise_std
164
+
165
+ weights = 1.0 / noise_std**2
166
+
167
+ # 加权最小二乘闭式解
168
+ W = np.diag(weights)
169
+ X = np.column_stack([np.ones_like(x), x])
170
+ beta_wls = np.linalg.inv(X.T @ W @ X) @ X.T @ W @ y
171
+ b_wls, a_wls = beta_wls
172
+
173
+ # 普通最小二乘
174
+ beta_ols = np.polyfit(x, y, 1)
175
+
176
+ y_pred_wls = a_wls * x + b_wls
177
+ y_pred_ols = beta_ols[0] * x + beta_ols[1]
178
+ r2_wls = 1 - np.sum((y - y_pred_wls)**2) / np.sum((y - np.mean(y))**2)
179
+ r2_ols = 1 - np.sum((y - y_pred_ols)**2) / np.sum((y - np.mean(y))**2)
180
+
181
+ print(f"真实: y = {true_a:.2f}x + {true_b:.2f}")
182
+ print(f"OLS: y = {beta_ols[0]:.3f}x + {beta_ols[1]:.3f}, R²={r2_ols:.4f}")
183
+ print(f"WLS: y = {a_wls:.3f}x + {b_wls:.3f}, R²={r2_wls:.4f}")
184
+ ```
185
+
186
+ ---
187
+
188
+ ## 示例 6:非线性最小二乘(通用方法)
189
+
190
+ ### 问题描述
191
+
192
+ 用 5 参数复合非线性模型 y = a*sin(b*x + c) + d*exp(-e*x) 拟合 50 组模拟数据。使用 `scipy.optimize.least_squares` 的 Trust Region Reflective 方法,带参数边界约束。
193
+
194
+ ### 代码实现
195
+
196
+ ```python
197
+ import numpy as np
198
+ from scipy.optimize import least_squares
199
+
200
+ def model(x, params):
201
+ a, b, c, d, e = params
202
+ return a * np.sin(b * x + c) + d * np.exp(-e * x)
203
+
204
+ np.random.seed(42)
205
+ x = np.linspace(0, 10, 50)
206
+ true_params = [2.0, 1.5, 0.5, 1.0, 0.3]
207
+ y = model(x, true_params) + 0.2 * np.random.randn(len(x))
208
+
209
+ def residuals(params, x, y):
210
+ return y - model(x, params)
211
+
212
+ result = least_squares(
213
+ residuals, [1.0, 1.0, 0.0, 0.5, 0.2],
214
+ args=(x, y),
215
+ bounds=([0, 0, -np.pi, 0, 0], [5, 3, np.pi, 3, 1]),
216
+ method='trf'
217
+ )
218
+
219
+ if result.success:
220
+ y_pred = model(x, result.x)
221
+ r2 = 1 - np.sum((y - y_pred)**2) / np.sum((y - np.mean(y))**2)
222
+ print(f"参数: {result.x}")
223
+ print(f"真实: {true_params}")
224
+ print(f"R² = {r2:.4f}, 迭代次数: {result.nfev}")
225
+ ```
226
+
227
+ ---
228
+
229
+ ## 示例 7:Lasso 特征选择
230
+
231
+ ### 问题描述
232
+
233
+ 50 个样本、20 个特征,仅 5 个特征对 y 有真实影响(稀疏性)。用 Lasso (L1 正则化) 自动特征选择,识别真正的信号特征。
234
+
235
+ ### 代码实现
236
+
237
+ ```python
238
+ import numpy as np
239
+ from sklearn.linear_model import Lasso
240
+ from sklearn.preprocessing import StandardScaler
241
+
242
+ np.random.seed(42)
243
+ n, p = 50, 20
244
+ X = np.random.randn(n, p)
245
+ true_coef = np.zeros(p)
246
+ true_coef[[0, 3, 7, 11, 15]] = [2.0, -1.5, 1.0, -0.8, 0.5]
247
+ y = X @ true_coef + 0.3 * np.random.randn(n)
248
+
249
+ scaler = StandardScaler()
250
+ Xs = scaler.fit_transform(X)
251
+
252
+ lasso = Lasso(alpha=0.1, max_iter=10000).fit(Xs, y)
253
+ selected = np.where(np.abs(lasso.coef_) > 1e-5)[0]
254
+ y_pred = lasso.predict(Xs)
255
+ r2 = 1 - np.sum((y - y_pred)**2) / np.sum((y - np.mean(y))**2)
256
+
257
+ print(f"选中特征: {selected}")
258
+ print(f"真实非零: {[0, 3, 7, 11, 15]}")
259
+ print(f"R² = {r2:.4f}")
260
+ ```
261
+
262
+ ---
263
+
264
+ ## 示例 8:有理函数拟合 (cubic/cubic) — NIST 高难度级
265
+
266
+ > **数据来源**:NIST Statistical Reference Datasets (StRD)
267
+ > https://itl.nist.gov/div898/strd/nls/nls_main.shtml
268
+ > 美国政府公共领域数据。引用:NIST ITL Statistical Engineering Division.
269
+
270
+ ### 问题描述
271
+
272
+ NIST StRD 级高难度非线性回归。37 组电子迁移率 (y) 与对数密度 (x) 数据,用 7 参数 cubic/cubic 有理函数拟合。该问题的难点:分母可能产生极点、存在局部极小值,常规 `lm` 方法难以收敛。
273
+
274
+ ```
275
+ x = [-3.067, -2.981, -2.921, -2.912, -2.840, -2.797, -2.702, -2.699,
276
+ -2.633, -2.481, -2.363, -2.322,
277
+ -1.501, -1.460, -1.274, -1.212, -1.100, -1.046,
278
+ -0.915, -0.714, -0.566, -0.545, -0.400, -0.309,
279
+ -0.109, -0.103, 0.010, 0.119, 0.377,
280
+ 0.790, 0.963, 1.006, 1.115, 1.572, 1.841,
281
+ 2.047, 2.200]
282
+ y = [80.574, 84.248, 87.264, 87.195, 89.076, 89.608, 89.868, 90.101,
283
+ 92.405, 95.854, 100.696, 101.060,
284
+ 401.672, 390.724, 567.534, 635.316, 733.054, 759.087,
285
+ 894.206, 990.785, 1090.109, 1080.914, 1122.643, 1178.351,
286
+ 1260.531, 1273.514, 1288.339, 1327.543, 1353.863,
287
+ 1414.509, 1425.208, 1421.384, 1442.962, 1464.350, 1468.705,
288
+ 1447.894, 1457.628]
289
+ ```
290
+
291
+ ### 代码实现
292
+
293
+ ```python
294
+ import numpy as np
295
+ from scipy.optimize import curve_fit
296
+
297
+ x_data = np.array([...]) # 见上方数据
298
+ y_data = np.array([...])
299
+
300
+ def rational_cubic_cubic(x, b1, b2, b3, b4, b5, b6, b7):
301
+ num = b1 + b2*x + b3*x**2 + b4*x**3
302
+ den = 1 + b5*x + b6*x**2 + b7*x**3
303
+ return num / den
304
+
305
+ # 多组初值 + 多方法尝试(关键策略)
306
+ p0_candidates = [
307
+ [1288.0, 1000.0, 500.0, 1400.0, 0.5, 0.5, 1.0],
308
+ [1300.0, 2000.0, 1000.0, 1500.0, 1.0, 1.0, 1.0],
309
+ [800.0, 100.0, 10.0, 500.0, 0.1, 0.01, 0.01],
310
+ [1000.0, 500.0, 200.0, 1400.0, 0.5, 0.2, 1.0],
311
+ [1500.0, 3000.0, 2000.0, 500.0, -1.0, 0.5, 0.5],
312
+ ]
313
+
314
+ best_rss = np.inf
315
+ best_result = None
316
+
317
+ for p0 in p0_candidates:
318
+ for method in ['lm', 'trf']:
319
+ try:
320
+ popt, pcov = curve_fit(rational_cubic_cubic, x_data, y_data,
321
+ p0=p0, method=method,
322
+ maxfev=200000, ftol=1e-12, xtol=1e-12)
323
+ y_pred = rational_cubic_cubic(x_data, *popt)
324
+ rss = np.sum((y_data - y_pred)**2)
325
+ if rss < best_rss:
326
+ best_rss = rss
327
+ perr = np.sqrt(np.diag(pcov))
328
+ best_result = (popt, perr, y_pred, rss, method, p0)
329
+ except:
330
+ pass
331
+
332
+ if best_result is None:
333
+ # 全局优化 fallback
334
+ from scipy.optimize import differential_evolution
335
+
336
+ def rss_obj(params):
337
+ pred = rational_cubic_cubic(x_data, *params)
338
+ return np.sum((y_data - pred)**2)
339
+
340
+ result = differential_evolution(rss_obj, [(-5000, 5000)]*7,
341
+ maxiter=5000, polish=True, seed=42)
342
+ popt = result.x
343
+ perr = np.full(7, np.nan)
344
+ else:
345
+ popt, perr, y_pred, rss, method, p0 = best_result
346
+
347
+ n = len(x_data)
348
+ r2 = 1 - rss / np.sum((y_data - np.mean(y_data))**2)
349
+ print(f"方法: {best_result[4] if best_result else 'differential_evolution'}")
350
+ for i in range(7):
351
+ print(f"b{i+1} = {popt[i]:.6E} ± {perr[i]:.6E}")
352
+ print(f"R² = {r2:.6f}")
353
+ ```
354
+
355
+ ---
356
+
357
+ ## 拟合方法选择指南
358
+
359
+ | 场景 | 推荐方法 | 调用方式 |
360
+ |------|----------|----------|
361
+ | 一元线性关系 | OLS | `np.linalg.lstsq` |
362
+ | 曲线趋势 | 多项式拟合 | `np.polyfit(x, y, deg)` |
363
+ | 已知函数形式 | curve_fit | `scipy.optimize.curve_fit` |
364
+ | 异方差数据 | 加权最小二乘 | `(X^T W X)^{-1} X^T W y` |
365
+ | 多重共线性 | Ridge | `sklearn.linear_model.Ridge` |
366
+ | 特征选择 | Lasso | `sklearn.linear_model.Lasso` |
367
+ | 有理函数 (cubic/cubic) | curve_fit (trf) + 多初值 | `scipy.optimize.curve_fit` |
368
+ | 全局优化困难 | differential_evolution | `scipy.optimize.differential_evolution` |
369
+
370
+ ## 诊断指标速查
371
+
372
+ | 指标 | 公式 | 含义 |
373
+ |------|------|------|
374
+ | R² | `1 - SS_res/SS_tot` | 拟合优度,越接近 1 越好 |
375
+ | RMSE | `sqrt(mean(res^2))` | 均方根误差,越小越好 |
376
+ | 残差平方和 (RSS) | `sum((y - y_pred)^2)` | 模型拟合总的未解释变异 |
377
+ | 条件数 | `max(s)/min(s)` | > 100 可能有共线性 |
378
+ | Durbin-Watson | `sum(diff(res)^2) / sum(res^2)` | 1.5-2.5 表示残差无自相关 |
379
+ | 参数 \|t\| 统计量 | `abs(param) / std_err` | > 2 表示参数显著 |
380
+ | 自由度 | `n - p` | 样本数减参数个数 |
@@ -0,0 +1,325 @@
1
+ ---
2
+ name: math-beamer
3
+ description: Use when creating, revising, or auditing source-grounded mathematical Beamer slide decks from papers, notes, proofs, lectures, experiments, or existing LaTeX slides across pure mathematics, applied mathematics, computational mathematics, statistics, optimization, geometry, topology, algebra, number theory, combinatorics, graph theory, logic, foundations, category theory, analysis, PDEs, dynamical systems, control theory, information theory, coding theory, cryptography, and teaching contexts.
4
+ ---
5
+
6
+ # Math Beamer
7
+
8
+ ## DSH Integration Notes
9
+
10
+ - 本技能由 `@louisultra/dsh-verymath` 插件提供;`templates/`(catalog + 23 个模板包 + 46 张预览)随包携带。
11
+ - 编译依赖 XeLaTeX/pdflatex/latexmk(本机 TeX Live 2025 已验证可编译 seminar-minimal-zh 模板)。
12
+ 编译前用 shell 检查 `kpsewhich forest.sty` / `which xelatex`;缺失时只交付 .tex 源码并告知安装路径,不要自动安装。
13
+ - 中文模板(course-lecture-zh / seminar-minimal-zh)需要 ctex 包(本机已确认可用)。
14
+ - 产物(.tex / .pdf / slide-source-ledger)写入当前会话工作区。
15
+ - 与 math-paper-reading 联动:`reading-group-paper` 模板 + 论文结构 JSON = "读论文→做组会报告"完整链路;
16
+ 与 osqp-solver 联动:`optimization-talk` 模板呈现优化结果。
17
+
18
+ Build and audit mathematical Beamer decks that are meant to be presented,
19
+ compiled, and traced back to source material. This skill covers mathematical
20
+ slide structure, not generic slide decoration.
21
+
22
+ ## Use When
23
+
24
+ Use this skill when the user wants to:
25
+
26
+ - turn a mathematical paper, lecture note, proof sketch, experiment log, or
27
+ theorem outline into a Beamer deck;
28
+ - revise an existing `.tex` Beamer project for mathematical clarity,
29
+ source-grounded claims, or build reliability;
30
+ - select a reusable template for a seminar, reading group, defense, course,
31
+ workshop, poster, or domain-specific math talk;
32
+ - audit theorem/proof/algorithm/formula/figure slides for notation,
33
+ assumptions, overclaiming, and layout risks;
34
+ - build a Chinese, English, or bilingual mathematics deck with reproducible
35
+ LaTeX commands.
36
+
37
+ Do not use this skill to invent results, prove unverified theorems, fabricate
38
+ citations, or make institutional-branded templates public without checking
39
+ license and logo rights.
40
+
41
+ ## Inputs
42
+
43
+ - Required: presentation goal, source packet, target audience, language, talk
44
+ duration or slide count, and preferred output folder.
45
+ - Optional: existing Beamer source, bibliography, figures, data files,
46
+ institutional style constraints, template choice, handout/poster mode,
47
+ speaker notes, and compile command.
48
+
49
+ If the source packet is missing, produce a source request or an outline of
50
+ needed evidence. Do not produce a full deck with unsupported claims.
51
+
52
+ ## Guided Interaction Contract
53
+
54
+ Default to guided mode unless the user explicitly requests autonomous
55
+ execution or has already supplied an approved brief, template, outline, and
56
+ sample direction.
57
+
58
+ - Work on one stage at a time. Ask only for decisions needed by the current
59
+ stage.
60
+ - End every guided response with a checkpoint containing:
61
+ - current stage;
62
+ - what was completed;
63
+ - the decision needed from the user;
64
+ - available responses: `approve`, `revise`, `reject`, `skip`, or `stop`;
65
+ - what will happen after approval.
66
+ - Do not interpret silence, a new attachment, or a general acknowledgement as
67
+ approval for a later stage.
68
+ - A user may combine stages only by explicitly providing the decisions for
69
+ each skipped checkpoint.
70
+
71
+ The following gates are mandatory in guided mode:
72
+
73
+ 1. **Brief gate**: confirm audience, language, duration, purpose, source of
74
+ truth, and output form.
75
+ 2. **Style gate**: show two or three suitable template candidates with cover
76
+ and content previews; wait for the user to choose one.
77
+ 3. **Outline gate**: present the talk thesis, section map, and slide budget;
78
+ wait for approval or revision.
79
+ 4. **Sample gate**: compile representative pages as described in Stage 4,
80
+ keeping the selected template's page types. Compare them with the selected
81
+ previews, then show the result for approval of typography, density, and
82
+ formula treatment within that template.
83
+
84
+ Do not build the full deck before all four gates have been approved or
85
+ explicitly skipped.
86
+
87
+ For the first response:
88
+
89
+ 1. inspect the available source packet;
90
+ 2. report the source inventory, likely mathematical genre, and missing
91
+ evidence;
92
+ 3. ask only for missing brief-gate decisions;
93
+ 4. state the next checkpoint.
94
+
95
+ Do not select a final template, write a full outline, or generate a full deck
96
+ in the first response unless the user explicitly requests autonomous execution.
97
+
98
+ ## Outputs
99
+
100
+ - Beamer source tree, usually `main.tex` plus figures, bibliography, and local
101
+ style files when needed.
102
+ - PDF build output when compilation is approved and tools are available.
103
+ - `slide-source-ledger.md` mapping slide claims, theorem statements, formulas,
104
+ algorithms, figures, and numeric results to sources.
105
+ - Build and layout report covering command, engine, warnings, errors,
106
+ references, citations, missing assets, fonts, and overfull boxes.
107
+ - Revision notes that distinguish mathematical meaning risks from mechanical
108
+ layout fixes.
109
+
110
+ ## Template Selection
111
+
112
+ Start from `templates/preview-gallery.md`, then confirm metadata in
113
+ `templates/catalog.yaml`. Inspect both the cover and first-content preview.
114
+ Filter the catalog to two or three candidates and present each candidate with:
115
+
116
+ - template name and preview paths;
117
+ - visual character and mathematical genre fit;
118
+ - strengths, density risks, language, and build engine;
119
+ - a recommendation without silently making the final choice.
120
+
121
+ Wait for the style-gate decision before drafting the outline. Select the
122
+ smallest template that matches the mathematical genre:
123
+
124
+ | Need | Template family |
125
+ | --- | --- |
126
+ | General seminar | `seminar-minimal-en`, `seminar-minimal-zh` |
127
+ | Theorem-heavy talk | `theorem-proof-talk` |
128
+ | Paper reading group | `reading-group-paper` |
129
+ | Optimization | `optimization-talk` |
130
+ | Numerical analysis / scientific computing | `numerical-analysis-talk` |
131
+ | Algorithms / complexity | `algorithm-talk` |
132
+ | Probability / statistics | `probability-statistics-talk` |
133
+ | Geometry / topology | `geometry-topology-talk` |
134
+ | Algebra / number theory | `algebra-number-theory-talk` |
135
+ | Combinatorics / graph theory | `combinatorics-graph-talk` |
136
+ | Logic / foundations / category theory | `logic-foundations-category-talk` |
137
+ | Core analysis | `analysis-core-talk` |
138
+ | PDE | `pde-analysis-talk` |
139
+ | Dynamical systems | `dynamical-systems-talk` |
140
+ | Control systems | `control-systems-talk` |
141
+ | Information / coding / cryptography | `information-coding-crypto-talk` |
142
+ | Experiment or data report | `data-experiment-results` |
143
+ | Chinese course lecture | `course-lecture-zh` |
144
+ | Thesis defense | `thesis-defense` |
145
+ | Workshop tutorial | `workshop-tutorial` |
146
+ | Backup-heavy research talk | `backup-heavy-talk` |
147
+ | Poster | `beamerposter-a0` |
148
+
149
+ Institutional or downloaded templates are references until their license,
150
+ branding, personal data, and build status are checked.
151
+
152
+ ## Preserve The Selected Template
153
+
154
+ The selected template defines the deck's layout as well as its colors. Apply
155
+ these rules in guided mode, autonomous mode, and later revisions. Skipping a
156
+ checkpoint does not discard an existing template choice.
157
+
158
+ - Record the selected template name, source path, cover/content previews, and
159
+ explicitly requested style changes in the existing brief or source packet.
160
+ Reuse that choice when continuing the work.
161
+ - Read the recorded template source and its local style files. For bundled
162
+ templates, the entry point is `templates/packs/<name>/main.tex`; for supplied
163
+ templates, use their actual entry point. Start the deck from those sources;
164
+ replace the title, author, date, sections, and frame contents while retaining
165
+ the template setup and layout commands. For an existing deck, continue from
166
+ its source and approved style changes.
167
+ - Preserve the theme, color and font settings, aspect ratio, margins, cover
168
+ structure, frame-title treatment, headline, footline, navigation, and block
169
+ styles. Keep the existing title-page mechanism, such as `\titlepage`.
170
+ Content may use suitable text, formulas, figures, tables, or columns within
171
+ that framework. Matching the palette alone is not template reuse.
172
+ - Treat requests to polish or improve layout as content adjustments within
173
+ the selected framework. Resolve overflow through shorter wording, formula
174
+ line breaks, or additional frames while preserving mathematical meaning.
175
+ Do not replace the cover, override template elements, or shrink global fonts
176
+ to make the content fit.
177
+ - If the user explicitly requests a style change, apply that change and retain
178
+ the other template elements. If proposing a redesign, show the specific
179
+ change for the user's decision before applying it. General approval of an
180
+ outline or sample does not permit further template changes.
181
+ - If the corresponding source is unavailable, state that limitation before
182
+ reconstructing a layout; do not describe a reconstruction as reuse of the
183
+ selected template.
184
+
185
+ Compare rendered samples and the final deck with the selected previews and
186
+ approved samples using `references/build-and-layout-audit.md`. Correct
187
+ unrequested style changes before delivery.
188
+
189
+ ## Guided Workflow
190
+
191
+ ### Stage 0: Source Intake
192
+
193
+ Inspect the source packet and identify the mathematical genre: theorem, proof,
194
+ algorithm, computation, experiment, survey, lecture, defense, or poster.
195
+ Separate confirmed sources from missing or conflicting evidence.
196
+
197
+ ### Stage 1: Brief Gate
198
+
199
+ Confirm audience, language, duration or slide count, presentation purpose,
200
+ authoritative source, output folder, build permission, and institutional
201
+ branding constraints. Recommend sensible defaults, but wait for approval.
202
+
203
+ ### Stage 2: Style Gate
204
+
205
+ Show two or three template candidates from the preview gallery. Explain the
206
+ tradeoffs and wait for the user to select or revise the shortlist.
207
+ If the user has already selected a template, carry that choice forward without
208
+ asking them to select it again. Record it as described above.
209
+
210
+ ### Stage 3: Outline Gate
211
+
212
+ Create a talk thesis, section map, and slide budget. Keep most talks to two to
213
+ four main sections unless the user requests a long lecture. Identify the role
214
+ of each planned theorem, proof, algorithm, figure, or experiment frame. Wait
215
+ for approval.
216
+
217
+ ### Stage 4: Sample Gate
218
+
219
+ Draft and compile at least one content-dense mathematical frame from the
220
+ selected template's source, plus its cover with actual metadata when the
221
+ template has a cover. For a single-page poster, use the compiled poster page.
222
+ Compare the rendered pages with the selected previews before showing them.
223
+ Keep the template's typography, colors, and page structure; review density,
224
+ notation, and formula treatment within that layout. Wait for sample approval.
225
+
226
+ ### Stage 5: Full Deck
227
+
228
+ Extend the approved sample source into the full deck, retaining the selected
229
+ template and explicit style changes. Build from source-grounded claims.
230
+ Preserve assumptions, domains, quantifiers, theorem status, proof status,
231
+ citations, and numeric results.
232
+ Write or update `slide-source-ledger.md` while drafting, not after the fact.
233
+
234
+ ### Stage 6: Build And Audit
235
+
236
+ Compile with the appropriate engine:
237
+ - English default: `latexmk -pdf -interaction=nonstopmode -halt-on-error main.tex`
238
+ - Chinese or mixed CJK default:
239
+ `latexmk -xelatex -interaction=nonstopmode -halt-on-error main.tex`
240
+
241
+ Audit the log, PDF, references, citations, figures, fonts, overfull boxes,
242
+ navigation, and frame density. Compare representative rendered pages with the
243
+ selected template and approved samples, including the cover when present.
244
+ Restore any unrequested template changes, including overrides introduced while
245
+ fixing layout. Report any change that could affect mathematical meaning.
246
+
247
+ ### Stage 7: Delivery
248
+
249
+ Return the deck, evidence ledger, build report, unresolved risks, and focused
250
+ revision options.
251
+
252
+ ## Mathematical Coverage Rules
253
+
254
+ - Pure mathematics: separate definitions, examples, theorem statements,
255
+ proof ideas, key lemmas, proof sketches, and limitations.
256
+ - Algebra and number theory: track notation, object categories, field/ring
257
+ assumptions, examples, and dependency diagrams.
258
+ - Geometry and topology: prefer diagrams and local-to-global structure maps;
259
+ record conventions for orientation, metrics, charts, homology, or bundles.
260
+ - Core analysis: preserve spaces, norms, operators, constants, convergence
261
+ modes, regularity, limiting arguments, and counterexamples.
262
+ - PDE: preserve function spaces, boundary conditions, regularity, constants,
263
+ domains, estimates, and weak/strong formulation choices.
264
+ - Combinatorics and graph theory: state finite/infinite setting, graph
265
+ conventions, extremal parameters, random model, and dependency method.
266
+ - Logic, foundations, and category theory: state formal system, semantics,
267
+ universe/size conventions, functorial direction, and coherence assumptions.
268
+ - Probability and statistics: state sample spaces, filtrations, distributions,
269
+ estimators, sample sizes, confidence or concentration statements, and
270
+ simulation conditions.
271
+ - Optimization: state variables, feasible sets, assumptions, algorithm steps,
272
+ convergence claims, rates, solver/data conditions, and failure modes.
273
+ - Numerical analysis and scientific computing: include discretization, error
274
+ metrics, stability conditions, implementation settings, and reproducibility.
275
+ - Dynamical systems: record phase space, invariant sets, stability notions,
276
+ bifurcation parameters, and qualitative diagrams.
277
+ - Control systems: record state/input/output spaces, controllability or
278
+ observability assumptions, stability notion, controller class, and robustness
279
+ margins.
280
+ - Information, coding, and cryptography: record alphabets, channel or adversary
281
+ model, rate/security parameter, asymptotic regime, and theorem status.
282
+ - Teaching decks: optimize for one concept per slide, worked examples, recap
283
+ frames, and exercises rather than paper-style claim density.
284
+
285
+ ## Review Rules
286
+
287
+ - Do not remove assumptions or quantifiers to fit a slide.
288
+ - Do not upgrade conjectures, heuristics, experiments, or proof sketches into
289
+ proved statements.
290
+ - Do not invent citations, theorem names, lemma dependencies, or numeric
291
+ results.
292
+ - Keep formulas readable using `align`, `split`, `multline`, `cases`, and
293
+ short prose anchors; avoid raw `$$`.
294
+ - Use overlays only when they help the argument. Overlays must not change
295
+ equation numbering or hide assumptions.
296
+ - Prefer relative paths for figures and data. Do not reference local absolute
297
+ paths.
298
+ - Treat institutional logos, school colors, and downloaded templates as
299
+ license-gated assets.
300
+
301
+ ## Failure Modes
302
+
303
+ - Missing source packet: list required sources and provide only a deck outline.
304
+ - Conflicting sources: identify the conflict and ask which source is
305
+ authoritative.
306
+ - Compile failure: report root file, command, engine, first fatal error,
307
+ missing files, unresolved references/citations, and the smallest next fix.
308
+ - Layout failure: identify overloaded frames, long formulas, overfull boxes,
309
+ unreadable figures, and title/navigation collisions.
310
+ - Template mismatch: restore the selected layout and explicit style changes,
311
+ recompile, and compare again. Do not present matching colors as compliance.
312
+ - License or branding uncertainty: keep the template in the reference index and
313
+ do not vendor it into public templates.
314
+
315
+ ## References
316
+
317
+ Read only the relevant files:
318
+
319
+ - `references/math-domain-patterns.md`
320
+ - `references/build-and-layout-audit.md`
321
+ - `references/template-source-index.md`
322
+ - `references/template-policy.md`
323
+ - `templates/preview-gallery.md`
324
+ - `templates/previews/`
325
+ - `templates/catalog.yaml`