【文章标题】:MathKernel: 一个具备证据感知能力的多引擎数学内核及MCP服务器
【文章正文】: An evidence-aware multi-engine mathematics kernel — usable both as a Python library (mathkernel) and as an MCP server (mathkernel-mcp) — so applications and LLMs can do advanced mathematics while preserving assumptions, provenance, and claim-specific evidence. 一个具备证据感知能力的多引擎数学内核——既可作为Python库(mathkernel)使用,也可作为MCP服务器(mathkernel-mcp)运行——使得应用程序和大型语言模型能够进行高级数学运算,同时保留假设、来源和特定声明证据。
The LLM interprets intent; the MathKernel establishes mathematical evidence. 大型语言模型负责解析意图;MathKernel则负责建立数学证据。
Mathematical results carry an explicit trust level, an engine tag, and a derivation trail. Exact computation, checked certificates, symbolic results, certified enclosures, empirical evidence, and formal proofs are distinct claims. Exact arithmetic alone is not a formal proof; approximate-input ancestry must not silently disappear. 数学结果携带明确的信任级别、引擎标签和推导轨迹。精确计算、验证证书、符号结果、认证包围、经验证据和形式证明是不同的声明类型。仅凭精确算术不能构成形式证明;近似输入的来源绝不能无声消失。
LLMs are good at mathematical intent and bad at mathematical arithmetic. MathKernel inverts the division of labor: the model parses, plans, and interprets; the kernel computes and records claim-specific evidence. Some claims use independent certificates or cross-checks; others are exact computations in one engine. Engine agreement alone is not a proof, and a single trust label does not replace the evidence bundle. 大型语言模型擅长数学意图解析却不擅长数学运算。MathKernel扭转了这种分工:模型负责解析、规划和解释;内核则负责计算并记录特定声明证据。某些声明使用独立证书或交叉验证;其他则是单一引擎中的精确计算。仅引擎一致并不构成证明,单一信任标签也无法替代证据包。
MathKernel is a typed orchestration layer rather than a single solver. The public facade owns parsing, contexts, object identity, persistence, evidence composition, resource policy and derivation tracking; domain adapters own the actual mathematics. Presentation layers sit downstream and cannot silently change the claim being made. MathKernel是一个类型化编排层而非单一求解器。公共门面层负责解析、上下文、对象标识、持久化、证据组合、资源策略和推导追踪;领域适配器则负责实际数学运算。呈现层位于下游,不能无声改变正在进行的声明。
Python / MCP | v MathKernel facade |— parser + contexts + typed objects |— execution/evidence contract |— persistence + derivation graph | +—> symbolic / exact / certified / formal / numerical engines | +—> MathResult and derived mathematical objects | +—> MultimodalProjection |—> mathkernel-viz |—> mathkernel-sonify +—> unified portable artifacts Python/MCP | v MathKernel门面层 |— 解析器 + 上下文 + 类型化对象 |— 执行/证据契约 |— 持久化 + 推导图 | +—> 符号/精确/认证/形式/数值引擎 | +—> MathResult及派生数学对象 | +—> 多模态投射 |—> mathkernel可视化 |—> mathkernel声效化 +—> 统一便携制品
This separation is deliberate: a renderer may present evidence, but it does not create stronger mathematical evidence merely by producing a polished plot or audio artifact. 这种分离是刻意的:渲染器可以呈现证据,但仅通过生成精美的图表或音频制品并不会创造更强的数学证据。
| Domain | Compute surface | Engines | Verification / evidence ceiling |
|---|---|---|---|
| 领域 | 计算表面 | 引擎 | 验证/证据上限 |
| Symbolic algebra | parse, substitute, simplify/expand/factor, solve, systems | SymPy | SYMBOLIC; input ancestry may lower it |
| 符号代数 | 解析、替换、简化/展开/因式分解、求解、方程组 | SymPy | 符号级;输入来源可能降低等级 |
| Calculus | differentiation, integration, limits, series, sums, products | SymPy | SYMBOLIC + conditions |
| 微积分 | 微分、积分、极限、级数、求和、乘积 | SymPy | 符号级+条件验证 |
| Integral transforms | Laplace/Fourier/Mellin/bilateral Z, inverses, ROC and property obligations | typed transform adapter + SymPy | SYMBOLIC; NUMERIC for approximate ancestry |
| 积分变换 | 拉普拉斯/傅里叶/梅林/双边Z变换、逆变换、收敛域及属性约束 | 类型化变换适配器+SymPy | 符号级;近似输入源为数值级 |
| Complex analysis | branches/domains, zeros/singularities, residues, Laurent series, contours, argument principle, continuation, conformal maps | typed complex adapter + SymPy | SYMBOLIC defining identities; EXACT winding certificates only for exact geometry, ancestry-capped otherwise |
| 复分析 | 分支/定义域、零点/奇点、留数、洛朗级数、围道、辐角原理、延拓、共形映射 | 类型化复数适配器+SymPy | 符号定义恒等式;仅精确几何有精确环绕证书,其他受限于输入源 |
| Continuous probability | typed univariate/joint/conditional distributions, transformations, marginals, Bayes, covariance, divergence, order statistics | typed probability adapter + SymPy | SYMBOLIC normalization/identity evidence; mathematical nonexistence retained |
| 连续概率 | 类型化单变量/联合/条件分布、变换、边缘分布、贝叶斯、协方差、散度、顺序统计量 | 类型化概率适配器+SymPy | 符号归一化/恒等证据;保留数学不存在性 |
| Exact graphs | typed simple/directed/weighted/multi graphs, traversal, components, shortest paths, MST, max-flow/min-cut, bipartite matching, Euler trails, coloring, topological sort, cycles, centrality, isomorphism | deterministic exact graph algorithms over Fraction + njit CSR traversal kernels | EXACT witness certificates; NP-hard optimality is OPTIMUM/CANDIDATE/IMPOSSIBLE/UNKNOWN, never heuristic nonexistence |
| 精确图论 | 类型化简单/有向/加权/多重图、遍历、连通分量、最短路径、最小生成树、最大流/最小割、二分图匹配、欧拉迹、着色、拓扑排序、环、中心性、同构 | 基于Fraction的确定性精确图算法+njit CSR遍历内核 | 精确见证证书;NP难问题最优解为OPTIMUM/CANDIDATE/IMPOSSIBLE/UNKNOWN,永不使用启发式不存在判定 |
| Exact combinatorics | combinatorial classes, exact counts, lazy generation, ordinary/exponential generating functions, recurrences | exact integer/ Fraction enumeration + SymPy + checked njit recurrence kernels | EXACT counts and recurrence/coefficient checks |
| 精确组合数学 | 组合类、精确计数、惰性生成、普通/指数生成函数、递推关系 | 精确整数/Fraction枚举+SymPy+验证型njit递推内核 | 精确计数及递推/系数验证 |
| Finite algebra | finite groups, permutation groups, abelian groups, homomorphisms, Z/nZ, GF(p^m), modules, Smith/Hermite normal forms | exact algebra + SymPy combinatorics + njit Cayley/GF(p)[x] kernels | EXACT axiom, homomorphism, irreducibility, and normal-form certificates |
| 有限代数 | 有限群、置换群、阿贝尔群、同态、Z/nZ、GF(p^m)、模、史密斯/埃尔米特范式 | 精确代数+SymPy组合数学+njit凯莱/GF(p)[x]内核 | 精确公理、同态、不可约性及范式证书 |
| Linear algebra | determinant, inverse, multiply, rank, RREF, eigenvalues, exact solves | SymPy | EXACT for exact arithmetic; otherwise ancestry-capped |
| 线性代数 | 行列式、逆矩阵、乘法、秩、行最简形、特征值、精确求解 | SymPy | 精确算术时为EXACT;否则受限于输入源 |
| Reasoning | obligation-DAG planning, equivalence, counterexamples | SymPy + Z3 + Lean | SYMBOLIC / EXACT / FORMAL by verifier |
| 推理 | 义务有向无环图规划、等价性、反例 | SymPy+Z3+Lean | 验证器决定的SYMBOLIC/EXACT/FORMAL |
| Certified numerics | arbitrary-precision evaluation and interval enclosures | mpmath + mpmath.iv | CERTIFIED NUMERIC or NUMERIC |
| 认证数值 | 任意精度求值和区间包围 | mpmath+mpmath.iv | CERTIFIED NUMERIC或NUMERIC |
| Integers | arbitrary precision, gcd/lcm, primality, factorization, CRT, modular arithmetic | exact + numba batch | EXACT |
| 整数 | 任意精度、最大公约数/最小公倍数、素数性、因式分解、中国剩余定理、模运算 | 精确+numba批处理 | EXACT |
| Code generation | TypeScript/Python/Rust emission, typecheck, symbolic round-trip, sandbox | compilers + SymPy | SYMBOLIC verification; never stronger than source |
| 代码生成 | TypeScript/Python/Rust输出、类型检查、符号往返、沙箱 | 编译器+SymPy | 符号验证;强度不超过源代码 |
| Binary fields | GF(2^m) arithmetic/construction and Rabin irreducibil | ||
| 二元域 | GF(2^m)算术/构造及Rabin不可约性 |