@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,116 @@
1
+ # Distilled Lean-Agent Capability Map
2
+
3
+ This reference is the contract for "distilling Lean agent ability" into the
4
+ AI4Math Lean skills. It separates three layers:
5
+
6
+ - `distilled default`: implemented as the normal coding-agent workflow without
7
+ external APIs or backend services;
8
+ - `adapter_recipe`: documented for explicit user-approved escalation, then
9
+ locally validated before acceptance;
10
+ - `not claimed`: related work that is cited as inspiration only.
11
+
12
+ Use "adapter recipe" in prose and `adapter_recipe` as the machine-readable
13
+ support status.
14
+
15
+ Do not claim parity with a specialist Lean prover unless the original backend
16
+ is actually configured, called, and its output is validated locally.
17
+
18
+ This is the distilled Lean-agent capability layer for the default skill path:
19
+ project gate, statement normalization, local context pack,
20
+ retrieve-before-inventing, bounded proof attempts, failed-route memory, local
21
+ validation, and minimal failure handoff.
22
+
23
+ ## Public Source Anchors
24
+
25
+ - Numina Lean Agent: https://github.com/project-numina/numina-lean-agent
26
+ - Public README describes an agent built on Claude Code for formal theorem
27
+ proving tasks, with tutorial setup, CLI skills, result directories, and
28
+ credentialed model/tool calls.
29
+ - project-numina/lean-lsp-mcp: https://github.com/project-numina/lean-lsp-mcp
30
+ - Public README describes an MCP server over Lean LSP with diagnostics, goal
31
+ states, hover information, local search, external theorem search, code
32
+ running, multi-attempt screening, and project build tools.
33
+ - LeanDojo / ReProver: https://leandojo.org/leandojo.html and
34
+ https://github.com/lean-dojo/ReProver
35
+ - Public materials describe retrieval-augmented theorem proving and
36
+ best-first search with a tactic generator.
37
+ - LeanCopilot: https://github.com/lean-dojo/LeanCopilot
38
+ - Public README describes native Lean tactics for tactic suggestion, proof
39
+ search, premise selection, and running LLMs from Lean.
40
+ - COPRA: https://github.com/trishullab/copra
41
+ - Public README describes an in-context proof agent for formal theorem
42
+ proving, with Lean setup, CLI use, experiments, and parallel theorem runs.
43
+
44
+ These sources are used to extract mechanisms. Do not copy private prompts,
45
+ benchmark-specific assumptions, or upstream implementation details.
46
+
47
+ ## Capability Status
48
+
49
+ | Capability | Source family | AI4Math status | Evidence or hook |
50
+ | --- | --- | --- | --- |
51
+ | Project gate: find Lake root, toolchain, mathlib revision, imports, build state | Numina, Lean LSP/MCP, LeanDojo | distilled default | `env`, `doctor`, `check`, direct Lake inspection |
52
+ | Statement normalization and preservation | Numina, COPRA, local coding-agent review | distilled default | `lean-formalization` playbook and `review` statement-drift guard |
53
+ | Theorem-state loop from concrete Lean errors/goals | LeanDojo/ReProver, Lean LSP/MCP, COPRA | distilled default | direct edit/check loop; optional MCP goal tools when approved |
54
+ | Local context pack: imports, nearby proofs, project declarations, failed attempts | LeanDojo/ReProver, Numina, LeanCopilot | distilled default | `rg`, nearby proof inspection, failed-strategy notes |
55
+ | Premise retrieval before invention | LeanDojo/ReProver, LeanCopilot, Lean LSP/MCP | distilled default plus `adapter_recipe` | local `rg`; optional `lean_local_search`, `lean_leansearch`, `lean_loogle`, `lean_state_search` through MCP |
56
+ | Bounded tactic/proof attempts | COPRA, LeanDojo/ReProver, LeanCopilot, Lean LSP/MCP | distilled default plus `adapter_recipe` | local iteration caps; optional `lean_multi_attempt` through MCP |
57
+ | External proof-search orchestration | Numina, COPRA | `built_in_recipe` or `adapter_recipe` | built-in Numina adapter; other backends follow `backend_adapter_checklist.md` |
58
+ | Native Lean tactic suggestion / proof search | LeanCopilot | adapter candidate | cite or use only when the target project imports/configures LeanCopilot |
59
+ | Lean LSP goal, hover, diagnostics, completions, declaration lookup | Lean LSP/MCP | `adapter_recipe` | `lean_lsp_mcp_adapter.md` |
60
+ | Semantic/external theorem search | Numina, Lean LSP/MCP, LeanDojo ecosystem | `adapter_recipe` | MCP external search tools or backend-specific skill keys after approval |
61
+ | Result directory, round limits, and run artifacts | Numina, COPRA | `built_in_recipe` or `adapter_recipe` | Numina runtime recipe and backend adapter checklist |
62
+ | Validation oracle | Lean itself, all source families | distilled default | `lake env lean`, `lake build`, `check`, `detect-sorry`, `review` |
63
+ | Minimal failure handoff | local skill design, COPRA-style stop condition | distilled default | `minimize-failure`, exact errors/goals, tried routes |
64
+
65
+ ## Distilled Default Loop
66
+
67
+ The default AI4Math Lean worker should behave like a distilled Lean agent even
68
+ when no backend or MCP server is configured:
69
+
70
+ 1. Gate the project: identify project root, toolchain, mathlib revision, imports,
71
+ and whether the target builds.
72
+ 2. Normalize the target: locate the authoritative statement, declaration name,
73
+ namespace, hypotheses, and whether statement changes are allowed.
74
+ 3. Build the context pack: current error/goal, nearby proofs, imported modules,
75
+ project declarations, relevant mathlib names, and tried routes.
76
+ 4. Retrieve before inventing: search local project and imports first; only add
77
+ helper lemmas after checking nearby/API-compatible declarations.
78
+ 5. Attempt bounded proof steps: try one small edit or tactic route at a time,
79
+ then run Lean and read the first concrete diagnostic.
80
+ 6. Record failed routes: do not cycle over the same tactic family, rewrite, or
81
+ statement weakening.
82
+ 7. Validate locally: final output must pass Lean/Lake checks and patch safety
83
+ guards.
84
+ 8. Hand off minimally when blocked: return the smallest failing Lean fragment,
85
+ exact goals/errors, tried routes, and the next mathematical decision.
86
+
87
+ ## Adapter Escalation
88
+
89
+ Escalate only when the user asks for Numina, official Lean Agent, Lean LSP/MCP,
90
+ Archon, LeanCopilot, batch proof search, or another external backend, or when
91
+ local bounded attempts are cycling and the user approves escalation.
92
+
93
+ Before escalation, document:
94
+
95
+ - target Lake project/file/folder;
96
+ - backend source and support status;
97
+ - setup location and network access;
98
+ - credentials, API keys, proxy, and MCP scope;
99
+ - command or MCP server configuration;
100
+ - mutation boundary and result directory;
101
+ - local validation gate and failure fallback.
102
+
103
+ The adapter result is only a proposal until local Lean/Lake validation and patch
104
+ review pass.
105
+
106
+ ## Acceptance Tests For This Skill
107
+
108
+ A delivery claiming Lean-agent capability distillation must include:
109
+
110
+ - this capability map;
111
+ - a Lean LSP/MCP `adapter_recipe`;
112
+ - `lean-formalization` text that names the distilled default loop, not only
113
+ related work;
114
+ - `verify-delivery` checks that require these references;
115
+ - at least one package-level test that fails if the distilled capability
116
+ references are removed.
@@ -0,0 +1,219 @@
1
+ # Lean LSP/MCP Adapter Recipe
2
+
3
+ Use this reference only when the user explicitly asks to connect Lean LSP/MCP,
4
+ Lean MCP, richer goal-state tooling, MCP-backed theorem search, or an optional
5
+ Lean-specialist backend that depends on MCP. The default coding-agent Lean path
6
+ does not require MCP.
7
+
8
+ Support status: `adapter_recipe`.
9
+
10
+ This file documents the boundary required before a coding agent may configure or
11
+ call a Lean LSP/MCP server. It does not make MCP a default dependency.
12
+
13
+ ## Upstream Source
14
+
15
+ Recommended public source:
16
+
17
+ - `project-numina/lean-lsp-mcp`: https://github.com/project-numina/lean-lsp-mcp
18
+
19
+ Source note: last checked 2026-07-01 against the public README. `uvx lean-lsp-mcp` is unpinned; record the resolved version or audited commit in setup evidence.
20
+
21
+ The public README describes a Lean theorem prover MCP server that talks to Lean
22
+ through the Language Server Protocol. It exposes diagnostics, goal states, hover
23
+ information, declaration lookup, completions, Lean snippet execution, multiple
24
+ attempt screening, local project search, external theorem search, and project
25
+ build tools. The README also documents VS Code, Cursor, and Claude Code setup,
26
+ including `uvx lean-lsp-mcp`, `LEAN_PROJECT_PATH`, optional search URLs, and
27
+ security risks.
28
+
29
+ ## When To Use
30
+
31
+ Use this adapter when the user asks for one of:
32
+
33
+ - "connect Lean MCP";
34
+ - "use Lean LSP/MCP";
35
+ - "show the current Lean goal through MCP";
36
+ - "use MCP theorem search";
37
+ - "run multiple proof attempts with MCP";
38
+ - "configure Claude Code / VS Code / Cursor MCP for this Lean project";
39
+ - "use Numina-style MCP tooling without a full Numina run".
40
+
41
+ Do not use this adapter just because a Lean proof is difficult. Try the default
42
+ distilled coding-agent loop first unless the user explicitly asks for MCP.
43
+
44
+ ## Setup Contract
45
+
46
+ Before configuring MCP, state these facts and ask for approval:
47
+
48
+ - The target must be a buildable Lake project. Run `lake build` manually first
49
+ when feasible so the LSP server starts faster and avoids timeout failures.
50
+ - The MCP server may access local files and run local Lean/build operations.
51
+ - Default transport: `stdio` only.
52
+ - `lean_run_code` is default-deny; expose it only inside a disposable trusted
53
+ sandbox after explicit user approval.
54
+ - External theorem search is local-only unless the user approves the remote service and data disclosure.
55
+ - External theorem-search tools may call remote services unless disabled,
56
+ replaced with self-hosted endpoints, or approved for the specific project.
57
+ - Any project-scoped MCP config, such as `.mcp.json`, is a source-controlled
58
+ file unless the user chooses a local/global scope.
59
+ - Review any existing project-scoped `.mcp.json` before enabling it.
60
+ - Allowlist direct `uvx lean-lsp-mcp` invocation or an audited pinned command;
61
+ reject shell wrappers, unexpected environment variables, and committed
62
+ secrets.
63
+ - Secrets such as bearer tokens must not be committed.
64
+
65
+ ## Readiness Checks
66
+
67
+ Run or ask the user/host to confirm:
68
+
69
+ ```bash
70
+ uvx --version
71
+ lake build
72
+ rg --version
73
+ ```
74
+
75
+ `rg` is optional but recommended for local search. If the project is large, use
76
+ `lake build` rather than relying on the MCP server to trigger the first build.
77
+
78
+ When a project path cannot be detected automatically, set:
79
+
80
+ ```bash
81
+ export LEAN_PROJECT_PATH="/absolute/path/to/lake/project"
82
+ ```
83
+
84
+ Set `LEAN_PROJECT_PATH` in every MCP client configuration.
85
+
86
+ ## MCP Client Configuration
87
+
88
+ Use the upstream documented command shape and choose the user's actual client.
89
+ Do not write config until the user approves the scope.
90
+
91
+ ### Claude Code
92
+
93
+ Run from the Lean project root:
94
+
95
+ ```bash
96
+ export LEAN_PROJECT_PATH="$PWD"
97
+ claude mcp add lean-lsp uvx lean-lsp-mcp
98
+ ```
99
+
100
+ For project-scoped config:
101
+
102
+ ```bash
103
+ export LEAN_PROJECT_PATH="$PWD"
104
+ claude mcp add lean-lsp -s project uvx lean-lsp-mcp
105
+ ```
106
+
107
+ Project-scoped config may create or update `.mcp.json`; review it before
108
+ committing.
109
+
110
+ ### VS Code
111
+
112
+ Use the MCP add-server workflow or equivalent `mcp.json` entry:
113
+
114
+ ```json
115
+ {
116
+ "servers": {
117
+ "lean-lsp": {
118
+ "type": "stdio",
119
+ "command": "uvx",
120
+ "args": ["lean-lsp-mcp"],
121
+ "env": {
122
+ "LEAN_PROJECT_PATH": "/absolute/path/to/lake/project",
123
+ "LEAN_LOG_LEVEL": "NONE"
124
+ }
125
+ }
126
+ }
127
+ }
128
+ ```
129
+
130
+ On Windows with WSL2, run the server inside WSL when the Lean project and
131
+ toolchain live there:
132
+
133
+ ```json
134
+ {
135
+ "servers": {
136
+ "lean-lsp": {
137
+ "type": "stdio",
138
+ "command": "wsl.exe",
139
+ "args": ["env", "LEAN_PROJECT_PATH=/absolute/path/to/lake/project", "uvx", "lean-lsp-mcp"]
140
+ }
141
+ }
142
+ }
143
+ ```
144
+
145
+ ### Cursor
146
+
147
+ Use Cursor MCP settings with:
148
+
149
+ ```json
150
+ {
151
+ "mcpServers": {
152
+ "lean-lsp": {
153
+ "command": "uvx",
154
+ "args": ["lean-lsp-mcp"],
155
+ "env": {
156
+ "LEAN_PROJECT_PATH": "/absolute/path/to/lake/project",
157
+ "LEAN_LOG_LEVEL": "NONE"
158
+ }
159
+ }
160
+ }
161
+ }
162
+ ```
163
+
164
+ Do not expose HTTP/SSE on `0.0.0.0` or a public interface. HTTP/SSE requires explicit approval, `127.0.0.1`, and a bearer token. Prefer local project config for private work and global config only when the user accepts the broader scope.
165
+
166
+ ## Tool Use Policy
167
+
168
+ Prefer MCP tools in this order:
169
+
170
+ 1. `lean_diagnostic_messages` to read current errors and warnings.
171
+ 2. `lean_goal` or `lean_term_goal` to inspect the exact proof state.
172
+ 3. `lean_hover_info`, `lean_declaration_file`, and `lean_completions` for
173
+ local symbol understanding.
174
+ 4. `lean_local_search` before external theorem search.
175
+ 5. `lean_leansearch`, `lean_loogle`, `lean_leanfinder`, `lean_state_search`, or
176
+ `lean_hammer_premise` only when the query is specific and the user has
177
+ approved the remote service, network use, and data disclosure for the
178
+ current project.
179
+ 6. `lean_multi_attempt` for bounded screening of a few candidate tactics.
180
+ 7. `lean_build` only after edits or when the LSP state needs a rebuild.
181
+
182
+ Do not call `lean_run_code` in the default adapter path. If a user explicitly
183
+ approves it, run only in a trusted disposable sandbox and still treat the result
184
+ as untrusted until local Lean/Lake validation passes.
185
+
186
+ Never accept an MCP result as final proof. The final gate remains local
187
+ Lean/Lake validation plus patch review.
188
+
189
+ ## Failure Triage
190
+
191
+ Common failures and responses:
192
+
193
+ - `lake build` is slow or times out: build manually first, then restart MCP.
194
+ - Project root not found: set `LEAN_PROJECT_PATH` to the Lake project root.
195
+ - Toolchain mismatch: inspect `lean-toolchain` and the active `elan` toolchain;
196
+ do not change project versions without approval.
197
+ - MCP server cannot access files: check client working directory and config
198
+ scope.
199
+ - External search is rate-limited, unavailable, or not approved: fall back to local `rg`,
200
+ `lean_local_search`, nearby proofs, and mathlib names.
201
+ - Security concern: use stdio by default, keep HTTP/SSE on `127.0.0.1` only
202
+ with an explicit bearer token when approved, and do not expose bearer tokens.
203
+
204
+ ## Validation Gate
205
+
206
+ After any MCP-assisted change:
207
+
208
+ ```bash
209
+ lake env lean path/to/file.lean
210
+ lake build
211
+ PYTHONDONTWRITEBYTECODE=1 python skills/lean-runtime/scripts/ai4m_lean.py review --before <before.lean> --after <after.lean>
212
+ PYTHONDONTWRITEBYTECODE=1 python skills/lean-runtime/scripts/ai4m_lean.py detect-sorry --file path/to/file.lean
213
+ ```
214
+
215
+ Use the helper paths relative to this repository when validating this skill
216
+ package; use the target project's own Lake root for user projects.
217
+
218
+ Reject output with `sorry`, `admit`, new `axiom`, unapproved theorem statement
219
+ drift, unreviewed generated files, or unvalidated backend edits.
@@ -0,0 +1,92 @@
1
+ # Lean Runtime Configuration
2
+
3
+ This skill uses a coding-agent Lean workflow by default. Local Lean/Lake is the primary validation layer. Optional backend integration is adapter-first; the official Numina runtime is a built-in recommended adapter recipe under ignored shared local state. See `numina_runtime.md` for Numina deployment and call details, and `backend_adapter_checklist.md` for other adapters.
4
+
5
+ ## Shared Layout
6
+
7
+ ```text
8
+ ${AI4MATH_HOME:-~/.ai4math}/
9
+ ├── lean-workspace/
10
+ ├── lean-workspaces/
11
+ ├── numina-runtime/
12
+ ├── logs/
13
+ └── failures/
14
+ ```
15
+
16
+ Repository-local machine settings still live under `<repo>/.ai4math/` and should not be committed. The reusable Lean workspace and built-in recommended Numina adapter runtime are shared by default so standalone tasks do not create a fresh workspace in every project.
17
+
18
+ ## Tool Checks
19
+
20
+ Use:
21
+
22
+ ```bash
23
+ python skills/lean-runtime/scripts/ai4m_lean.py doctor --cwd .
24
+ python skills/lean-runtime/scripts/ai4m_lean.py env --cwd .
25
+ ```
26
+
27
+ Required default workflow tools are `git`, `python3`, `elan`, `lean`, and `lake`. Backend adapter setup may additionally report adapter-specific tools such as `curl`, `uv`, and `claude`. Numina adapter calls need a working Claude CLI/auth path and may need additional API keys for search/tool skills.
28
+
29
+ ## Reusable Lean Workspace
30
+
31
+ For standalone tasks, prefer `${AI4MATH_HOME:-~/.ai4math}/lean-workspace`. This canonical managed workspace defaults to the AI4Math baseline toolchain `leanprover/lean4:v4.28.0`; use `--toolchain` only as an explicit override. Create it once with:
32
+
33
+ ```bash
34
+ python skills/lean-runtime/scripts/ai4m_lean.py configure --cwd . --create-workspace
35
+ ```
36
+
37
+ Equivalent Lake commands:
38
+
39
+ ```bash
40
+ elan run leanprover/lean4:v4.28.0 lake new lean_workspace math
41
+ elan run leanprover/lean4:v4.28.0 lake update
42
+ elan run leanprover/lean4:v4.28.0 lake exe cache get
43
+ elan run leanprover/lean4:v4.28.0 lake build
44
+ ```
45
+
46
+ If a user project already has `lean-toolchain` and `lakefile.{lean,toml}`, use that project and do not change versions without approval. If the canonical workspace already has `lake-manifest.json` and `.lake/`, reuse it instead of rerunning cache/build. If a standalone task needs a different Lean/mathlib revision than the shared managed workspace, use a versioned workspace under `${AI4MATH_HOME:-~/.ai4math}/lean-workspaces/` instead of overwriting `${AI4MATH_HOME:-~/.ai4math}/lean-workspace`.
47
+
48
+ ## Partial Readiness
49
+
50
+ Report readiness in two layers:
51
+
52
+ - Lean core ready: `lean --version`, `lake --version`, and a pure Lean smoke theorem pass.
53
+ - mathlib ready: `lake update`, `lake exe cache get`, `lake build`, and `import Mathlib` pass in the selected Lake project.
54
+
55
+ When Lean core ready passes but mathlib ready is blocked by GitHub, proxy, or cache download failure, call this degraded mode or partial readiness. Pure Lean compilation is available, but Mathlib-dependent work is not ready. The next action should be Git/mathlib recovery, not Numina setup or Mathlib-dependent formalization.
56
+
57
+ Useful Windows diagnostics and recovery commands:
58
+
59
+ ```powershell
60
+ git ls-remote https://github.com/leanprover-community/mathlib4.git HEAD
61
+ Remove-Item -Recurse -Force .lake\packages\mathlib
62
+ lake update
63
+ lake exe cache get
64
+ lake build
65
+ ```
66
+
67
+ If `git ls-remote` fails, fix Git proxy/network inheritance first. If it succeeds and Lake reports a corrupt `.lake\packages\mathlib` checkout or cannot resolve `HEAD`, remove that package directory and rerun `lake update`.
68
+
69
+ ## Local Config
70
+
71
+ Machine-specific settings live in `.ai4math/lean_agent.local.toml` and should not be committed. Example:
72
+
73
+ ```toml
74
+ [lean]
75
+ workspace_mode = "reuse-managed"
76
+ managed_workspace_path = "~/.ai4math/lean-workspace"
77
+ align_workspace_versions = true
78
+ preferred_toolchain = "leanprover/lean4:v4.28.0"
79
+
80
+ [agent]
81
+ mode = "coding-agent"
82
+ backend = "none"
83
+ ```
84
+
85
+ Environment overrides:
86
+
87
+ ```bash
88
+ export AI4MATH_HOME="~/.ai4math"
89
+ export AI4MATH_LEAN_WORKSPACE="~/.ai4math/lean-workspace"
90
+ export AI4MATH_LEAN_TOOLCHAIN="leanprover/lean4:v4.28.0"
91
+ export AI4MATH_NUMINA_HOME="~/.ai4math/numina-runtime"
92
+ ```
@@ -0,0 +1,80 @@
1
+ # Numina and Lean-Specialist Agent Pattern Integration
2
+
3
+ This reference records how this coding-agent Lean skill incorporates mechanisms from the public Numina Lean Agent workflow, and how those mechanisms fit the broader Lean-specialist agent pattern library in `specialist_agent_patterns.md`. For deployment/call instructions, use `numina_runtime.md`.
4
+
5
+ ## Source Scope
6
+
7
+ - Public repository: https://github.com/project-numina/numina-lean-agent
8
+ - Result repository: https://github.com/project-numina/Numina-Putnam2025
9
+ - Paper reference: https://arxiv.org/abs/2601.14027
10
+
11
+ The goal is not to copy Numina prompts or reimplement Numina proof search. The goal is to incorporate reusable Lean-agent mechanisms into a comprehensive coding-agent skill while preserving a deployable path to the official Numina runtime as a built-in recommended adapter recipe.
12
+
13
+ ## Incorporated Patterns
14
+
15
+ 1. Use a coding agent as the primary Lean worker, with Numina available as a recommended optional backend adapter.
16
+ 2. Keep Lean/Lake validation as the correctness oracle.
17
+ 3. Treat theorem statement preservation as a first-class safety check.
18
+ 4. Work in bounded rounds with a clear stopping condition.
19
+ 5. Preserve structured run state: task type, target, changed files, validation result, remaining errors/goals, and next action.
20
+ 6. When blocked, reduce the problem to the smallest useful failing Lean fragment.
21
+ 7. Prefer reusable Lean workspaces so setup cost is not paid on every standalone problem.
22
+
23
+ ## Optional Runtime State
24
+
25
+ The default AI4Math coding-agent loop does not require these runtime dependencies, but the built-in recommended Numina adapter path does:
26
+
27
+ - upstream Numina repository checkout;
28
+ - Numina Python environment;
29
+ - external prover backend command construction;
30
+ - model endpoint configuration;
31
+ - API-key or login setup;
32
+ - backend round streaming or benchmark execution.
33
+
34
+ Those concerns are handled by the official upstream checkout under `${AI4MATH_HOME:-~/.ai4math}/numina-runtime/` and the human-in-the-loop flow in `numina_runtime.md`.
35
+
36
+ ## Coding-Agent-First Workflow
37
+
38
+ ```mermaid
39
+ flowchart TD
40
+ A["User asks for Lean work"] --> B["Coding agent classifies task"]
41
+ B --> C["Inspect Lean project or shared workspace"]
42
+ C --> D["Coding agent edits Lean directly"]
43
+ D --> E["Run Lean/Lake check"]
44
+ E --> F{"Verified without unsafe placeholders?"}
45
+ F -->|yes| G["Review patch and return result"]
46
+ F -->|no| H{"Use local iteration or approved backend adapter?"}
47
+ H -->|yes| D
48
+ H -->|adapter| N["Call approved backend adapter after approval"]
49
+ N --> E
50
+ H -->|blocked| I["Extract minimal failure and report exact errors/goals"]
51
+ ```
52
+
53
+ ## AI4Math Skill Mapping
54
+
55
+ | Numina idea | AI4Math implementation |
56
+ | --- | --- |
57
+ | Environment gate before proof attempts | `env`, `doctor`, `configure`, `check` |
58
+ | Official runner invocation | Optional `${AI4MATH_HOME:-~/.ai4math}/numina-runtime/upstream` with documented Numina commands |
59
+ | Bounded proof rounds | `max_local_iterations` / `max_rounds` |
60
+ | Statement drift guard | `validate_patch.py` |
61
+ | Placeholder guard | `detect_sorry.py` and `review` |
62
+ | Minimal blocked artifact | `extract_minimal_failure.py` |
63
+ | Reusable project context | `${AI4MATH_HOME:-~/.ai4math}/lean-workspace` |
64
+
65
+ ## Failure Lessons
66
+
67
+ - Standalone Lean files need a project context; the skill supplies a managed workspace.
68
+ - Long proof attempts should wait until a natural-language statement has been translated and confirmed.
69
+ - A patch that proves an easier theorem is a failure unless the user approved the statement change.
70
+ - Partial progress is valuable only when the remaining Lean errors/goals are preserved precisely.
71
+
72
+ ## Practical Rule
73
+
74
+ If a future agent reads this file during normal Lean work, the default action item is:
75
+
76
+ 1. verify local Lean readiness;
77
+ 2. prepare the target in the user's Lake project or shared workspace;
78
+ 3. edit/check directly as a coding agent;
79
+ 4. use a backend adapter only if the user asks for that adapter path or it is approved;
80
+ 5. return a verified patch or minimal failure.
@@ -0,0 +1,41 @@
1
+ # Optional Official Numina Backend Adapter
2
+
3
+ This skill keeps the official `project-numina/numina-lean-agent` repository as a built-in recommended Lean-specialist backend adapter in the adapter-first backend design. The default path is coding-agent Lean work with local Lean/Lake validation; Numina is used when the user asks for the official Lean Agent, Numina, batch proof search, or an approved external subagent run.
4
+
5
+ Built-in recommended adapter: official Numina Lean Agent runtime.
6
+
7
+ Numina and Archon are recommended adapter candidates, not defaults or hard requirements. Other Lean-specialist backends may be connected by the coding agent through the backend adapter checklist; do not call any backend until deployment, readiness checks, invocation, validation, and failure triage are documented. See `backend_adapter_checklist.md` before connecting Archon or any other backend.
8
+
9
+ ## Agent Flow
10
+
11
+ 1. Clarify the target: configure the built-in recommended Numina adapter, call Numina on a Lean project/file/folder, validate Numina output, or continue with the default coding-agent path.
12
+ 2. Run `doctor --cwd .` when useful and read the `numina` readiness block before recommending a path.
13
+ 3. Explain what setup may do: clone the official repository, run `tutorial/setup.sh`, install or use `elan`, `lake`, `curl`, `uv`, and `claude`, and require model/API credentials or Claude CLI auth for calls.
14
+ 4. After approval, run `configure --cwd . --setup-numina --project-name <name>`. Use `--dry-run` first when the user wants to review commands.
15
+ 5. For an official Numina subagent run, call the upstream runner from `${AI4MATH_HOME:-~/.ai4math}/numina-runtime/upstream` using its documented interface, normally `uv run python -m scripts.run_claude from-folder <target> --prompt-file prompts/autosearch/main_entry.md --max-rounds <n> --result-dir <dir>`.
16
+ 6. After Numina changes Lean files, use local `check`, `detect-sorry`, and `review` before accepting the patch.
17
+
18
+ Default to the shared Lean workspace for user tasks. Upstream Numina examples or benchmarks may pin their own `lean-toolchain`; that only describes the example project, not the readiness of `${AI4MATH_HOME:-~/.ai4math}/lean-workspace`.
19
+
20
+ ## Local State
21
+
22
+ - Runtime root: `${AI4MATH_HOME:-~/.ai4math}/numina-runtime/`
23
+ - Upstream checkout: `${AI4MATH_HOME:-~/.ai4math}/numina-runtime/upstream/`
24
+ - Ignored credential file: `${AI4MATH_HOME:-~/.ai4math}/numina-runtime/.env.local`
25
+ - Suggested outputs: `${AI4MATH_HOME:-~/.ai4math}/numina-runtime/results/`
26
+
27
+ Do not commit runtime state, API keys, generated results, or local machine paths.
28
+
29
+ ## Credentials
30
+
31
+ Claude authentication can come from the user's normal Claude CLI login or environment variables such as `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_BASE_URL`, and `ANTHROPIC_MODEL`. Numina's CLI skills may also need `GEMINI_API_KEY`, `OPENAI_API_KEY`, `LEAN_LEANDEX_API_KEY`, or `AXLE_API_KEY`.
32
+
33
+ If the user asks whether API keys are needed, distinguish the two paths: the default coding-agent Lean workflow and local Lean validation do not need API keys; Numina adapter calls need a working Claude CLI/auth path and may need additional keys for search/tool skills.
34
+
35
+ The helper readiness report redacts values and only reports whether keys appear configured.
36
+
37
+ For authentication, proxy, MCP scope, and runner failure triage, use `numina_subagent_troubleshooting.md`.
38
+
39
+ ## Boundary
40
+
41
+ The AI4Math skill still owns delivery quality. Official Numina may propose or edit proofs, but final acceptance requires local Lean/Lake validation and the usual patch safety checks: no `sorry`, no `admit`, no newly introduced `axiom`, and no theorem statement drift unless explicitly approved.
@@ -0,0 +1,77 @@
1
+ # Numina Subagent Troubleshooting
2
+
3
+ Use this reference when the optional official Numina subagent path fails during setup, authentication, proxy routing, MCP/tool scope, runner execution, or Lean validation. Keep the default coding-agent Lean path available unless the user specifically requires Numina.
4
+
5
+ ## Checkpoint Format
6
+
7
+ Report failures as:
8
+
9
+ ```text
10
+ [check] <what was checked>
11
+ [pass/fail] <result>
12
+ [next action] <one concrete command or decision>
13
+ ```
14
+
15
+ Do not expose API key values. Only report whether a credential appears configured.
16
+
17
+ ## Authentication Modes
18
+
19
+ Mode A: Claude CLI or Anthropic-compatible environment.
20
+
21
+ Required signals:
22
+
23
+ - `claude` is installed and authenticated, or `ANTHROPIC_AUTH_TOKEN` is configured;
24
+ - `ANTHROPIC_BASE_URL` is set when using a non-default endpoint;
25
+ - `ANTHROPIC_MODEL` names the intended model.
26
+
27
+ Mode B: Gemini or another provider through LiteLLM/Anthropic-compatible proxy.
28
+
29
+ Required signals:
30
+
31
+ - upstream key such as `GEMINI_API_KEY` is configured;
32
+ - LiteLLM or the team gateway is reachable;
33
+ - `ANTHROPIC_BASE_URL` points to the proxy;
34
+ - `ANTHROPIC_AUTH_TOKEN` is set to the proxy token expected by that gateway;
35
+ - a small `/v1/messages` probe succeeds before running Numina.
36
+
37
+ ## Proxy Checks
38
+
39
+ When `ANTHROPIC_BASE_URL` is not the public Anthropic endpoint:
40
+
41
+ - check that the base URL is reachable from the same shell that will run Numina;
42
+ - verify proxy logs if the request reaches the proxy but model routing fails;
43
+ - separate network failure from model-auth failure.
44
+
45
+ Typical next actions:
46
+
47
+ - proxy unreachable: start LiteLLM or fix `ANTHROPIC_BASE_URL`;
48
+ - `401` or auth error: refresh token/key and rerun readiness;
49
+ - model not found: align `ANTHROPIC_MODEL` with the proxy route.
50
+
51
+ ## MCP Scope
52
+
53
+ If the official runner or Claude CLI tools depend on MCP:
54
+
55
+ - add/list MCP servers from the target Lean project directory, not from an unrelated folder;
56
+ - confirm `claude mcp list` shows the expected server in the same directory context;
57
+ - rerun the Numina command from the project root or the documented upstream runner cwd.
58
+
59
+ If MCP works globally but fails in a project, treat it as a scope/cwd problem first.
60
+
61
+ ## Failure Routing
62
+
63
+ - `401`, `AuthenticationError`, or invalid token: credentials or proxy auth.
64
+ - connection refused, timeout, DNS, or TLS error: proxy/network endpoint.
65
+ - `mcp` server missing, disconnected, or wrong cwd: MCP scope.
66
+ - `lake` or `lean` failure before Numina starts: target project is not buildable.
67
+ - `lean-toolchain` download failure in upstream examples: example project issue, not necessarily shared workspace failure.
68
+ - Numina produces Lean with `sorry`, `admit`, new `axiom`, or statement drift: reject output and validate/minimize locally.
69
+
70
+ ## Recovery Order
71
+
72
+ 1. Preserve the user's target file and theorem statement.
73
+ 2. Verify local Lean workspace or target Lake project.
74
+ 3. Verify Numina runtime and upstream checkout.
75
+ 4. Verify Claude/API/proxy/MCP readiness only if Numina will be called.
76
+ 5. Run the smallest approved Numina command.
77
+ 6. Validate all changed Lean files locally before returning success.
@@ -0,0 +1,10 @@
1
+ # Review Checklist
2
+
3
+ Before accepting a Lean patch:
4
+
5
+ 1. Run `detect-sorry` or `review`.
6
+ 2. Confirm no `sorry`, `admit`, or newly introduced `axiom`.
7
+ 3. Confirm theorem/lemma declarations were not weakened unless approved.
8
+ 4. Run `lake env lean <file>` or `check` when available.
9
+ 5. If validation fails, run `minimize-failure`.
10
+ 6. Report remaining errors and exact next action.