跳到正文
Hacker News (official RSS)(samosa-math.vercel.app)·· 26 天前品質評分72

Show HN:Samosa 數學推導 Linter

Show HN: Samosa – Linter for Math Derivations

重點導讀

Samosa 是一款可在瀏覽器、CLI 或 CI 環境中使用的數學推導 Linter,透過在有限域上隨機矩陣驗證每一步,並提供最小可讀反例與修正建議。

\n- 核心功能:自動檢查等式、形狀、梯度、Hessian 等,並在失敗時給出最小反例與修正。

AI 伴隨問答

自備 Key 深度分析

針對這篇報導有疑問?可直接點選快捷問題或向 AI 追問背景脈絡與技術細節:

正文
  • ›every step, checked
  • ›counterexamples, not vibes

An ASCII art samosa shaped like the nabla symbol, turning slowly in the dark.

drag to spin · click for snack mode

SAMOSA checks every step of your derivation by evaluating it on random matrices: exactly, over finite fields. Wrong steps come with the smallest counterexample and a fix.

THE AGENT SESSION

Your agent can check its own math

SAMOSA ships an MCP server and an Agent Skill, so Claude Code, Codex or Cursor can verify a derivation before they hand it to you. The verdict comes from the engine, never from the model.

  • ›The tool call is small. One function, one derivation, one report.
  • ›The verdict is evidence. Every checkmark carries the sizes, the trials, the primes and the bound.
  • ›Nothing is uploaded. The link that comes back keeps the derivation in the fragment of the URL.

NINETEEN SECONDS

The line nobody checks

The moment every derivation has: after some algebraic manipulation, we may obtain. SAMOSA reads that line, evaluates it over a finite field, and brings a counterexample you can read.

Video 3

WHAT IT DOES

6 things, all of them useful

SAMOSA never guesses. When it does not know, it says so, and tells you what to declare.

Counterexamples

Not "the numbers differ". The smallest instance that breaks the step, shrunk until it is small enough to read.

✗ row 4 · the two sides are not equal

C_t =
[ 1 ]
Q_t =
[ 5 ]
\bar\Sigma_t =
[ 5 ]
\Sigma_t (computed) = 2.5
K_t (computed) = 0.5

Fixes

The common mistakes, tried for you: a transposed product, a missing noise term, a factor of two.

this step is off by exactly

change the right side to

Shape errors

When the sizes do not fit, SAMOSA says which sizes do not fit, and suggests the transpose you forgot.

⊘ row 3 · in a product: the sizes n and m do not match

C_t is m by n
the inner sizes do not match

a transpose is missing

Gradients

Gradients and Hessians are checked with dual numbers, so the layout convention is diagnosed, not guessed.

✗ row 2 · the numerator layout

the gradient has the shape
of the variable it is taken with
respect to. Transpose it.

Guarantees

A checkmark without a bound is a guess. Every verdict carries the probability that a wrong step slipped through.

✓ row 11 · holds at every size tested

sizes (3,2) (2,3) (4,3)
6 trials each · 2 primes
d ≤ 43 · false-✓ ≤ 1e-46

Your pipeline

A CLI, a GitHub Action and an MCP server. The same engine, so the verdicts never disagree.

$ npx samosa-math check paper.tex
132:18 ✗ wrong not equal
141:5 ⊘ shape n ≠ m
✗ 1 wrong · ⊘ 1 shape · ✓ 41 · 38 ms

SAMOSA-SERVATIONS

(AB)ᵀ ≠ AᵀBᵀ, bestie

you dropped + KQKᵀ

that's numerator layout 👀

≈ is not =

THE HALL OF BUGS

Real mistakes, caught by a machine

The kinds of slip that survive a proof, a code review and a careful read of the paper.

HOW IT WORKS

6 ideas, no magic

There is no model in the loop. There is arithmetic, a finite field and a probability bound.

01

Exact, not approximate

A step that only uses rational operations is checked over a finite field, where a wrong step survives with probability at most d/p. SAMOSA computes that d, and shows it to you.

read more →

the guarantee card

sizes(3,2) (2,3) (4,3)

trials per size 3

primes 2³¹−1 · 2147483629

degree bound d = 9

a false ✓ is at most 5.4 × 10⁻⁵¹

02

Gradients by dual numbers

A derivative is a pair, a value and a tangent. Multiply them, and the tangent chain rule comes out on its own, exactly, over the same field.

read more →

a derivative is a pair

(v, v̇) ⊗ (w, ẇ)

= (v w, v̇ w + v ẇ)

(x, 1) ⊗ (x, 1)

= (x², 2x)

the tangent rides along, exactly, over the same field

03

Counterexamples that shrink

A counterexample over a finite field is unreadable. SAMOSA looks for a small integer instance that still breaks the step, the way a fuzzer shrinks a failing case.

read more →

shrink until a person can read it

2 1 0 1 0 3 1 0 1 0 2 1 0 1 0 1

4 by 4

→

[ 1 ]

1 by 1

still wrong, and now readable

04

Built for agents

An MCP server and an Agent Skill, so your agent can check the matrix algebra before it hands the derivation to you.

read more →

an agent, checking its own work

tool samosa.check_derivation

args kalman.tex

→ row 7 ✗ wrong

an inverse where there should be none

→ fix applied · 8/8 rows hold

05

In your pipeline

A CLI and a GitHub Action that lint the align blocks of a paper, and fail the build when a step is wrong.

read more →

the pull request, annotated

::error file=paper/appendix.tex,line=132,col=18

the two sides are not equal

off by exactly + K_t Q_t K_tᵀ

the job failed with 1 error

06

It reads real papers

Of the claim rows in the display math of 36 recent papers, 56.3% parses end to end and 24.9% is read with no named unknown construct. The first measurement was lenient; this one parses the whole row, and the correction is published.

read more →

36 papers, measured

claim rows 1219

197 rows make no claim, and are not counted

parses end to end 56.3%

no unknown construct 24.9%

the first number was lenient; this one parses the whole row. the second is an upper bound, because the run does not read the preamble

INSTALL

One click, or one line

The web app needs nothing. The CLI and the MCP server need npm, and that is all.

In your browser

No account, no upload, no server. The engine runs in a worker, in the tab, and the derivation never leaves the device.

Open the app

In your agent and your CI

The npm package carries the CLI, the MCP server and the GitHub Action. The same engine gives the same verdicts everywhere.

npx samosa-math check paper.tex claude mcp add samosa uses: Hussain004/SAMOSA@v1

Open the app, paste a derivation, read the verdicts. Everything runs in your browser, and the share link keeps it in the URL fragment.

ANNOUNCEMENTS

2026-10-21

The first release

The engine, the app, the CLI, the MCP server and sixteen derivations.

2026-10-21

The Joseph form

The Kalman update, with its two planted bugs.

2026-10-21

Dual numbers

Gradients and Hessians, checked exactly over a finite field.

來源: Hacker News (official RSS) (samosa-math.vercel.app)
開啟原文

讀者討論

理性交流 · 即時討論