Grounded Proof Completion & Animation #378
ibenian
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
AlgeBench can take a starting expression and a target expression, ask an LLM to write the step‑by‑step derivation between them, verify every step with a computer‑algebra system, rank how confident we are in each step, and then animate the whole thing as a smooth, morphing transformation on the semantic graph — with a confidence badge on each step that never overclaims.
Quadratic.Roots.mov
(Live Examples)
This post is the 10,000‑ft tour. Each numbered section below is really its own deep‑dive — I'll expand each into a standalone post later.
The big picture
One sentence: an LLM writes the math, a CAS judges it, and a deterministic renderer animates it — confidence flows all the way to a badge the user sees.
1. How proof completion works
The model never touches graphs. It's given the start and target as LaTeX and asked to emit a single trajectory of steps. Each step is one mathematical move plus the complete expression you reach after it:
operationexpr_latexx^2 + \frac{b}{a}x = -\frac{c}{a}justificationchange_typerewrite·solve·substitute·approximate·givenIt's a thin DSPy module —
dspy.ChainOfThought(ProofCompletionSig)— so the prompt itself is optimizable (MIPROv2/GEPA), and the expert binds the start/target LaTeX from the context graphs before inference.The crucial design choice: the model emits full expressions, not graph edits. That keeps it doing what LLMs are good at (math in LaTeX) while the code side owns everything structural.
Here it is end‑to‑end on a product‑rule derivative — a real, unedited CLI run against the uncompiled baseline with refinement and the LLM‑judge off (
--attempts 1, no--judge), so you're seeing the raw model + grounding:The model applied the product rule, differentiated each factor, and every transition is symbolically proven (🥇). Note
exact graph: ✗whilemath correct: ✓— the final tree isn't node‑for‑node identical to the parsed target (a·bvsb·aordering), but SymPy confirms they're equal, which is why the endpoint gate still passes.2. How grounding works — semantic graph + SymPy
This is the heart of "grounded." Every state the model wrote is turned into a semantic graph, the graph is reconstructed into a SymPy expression, and each transition
state[k‑1] → state[k]is classified by what SymPy can prove.flowchart TD L[state LaTeX] --> G[semantic graph] G --> S[graph_to_sympy] S --> R{relation to previous state} R -->|sympy_equiv holds| EQ[equivalent] R -->|solution set is subset| NA[narrows] R -->|landmarks or solutions differ| RF[refuted] R -->|CAS cannot decide| UN[unknown] EQ --> T[tier] NA --> T RF --> T UN --> TThe checks run cheapest‑first and stop at the first that decides: symbolic equivalence → exact solution‑set containment → squared/branch pair for roots → scaled residual for multiply/divide both sides → parametric narrowing for multivariate → a characteristic fingerprint (real roots, singularities, limits — landmarks, not random sampling) → numeric tolerance for declared approximations. Each consecutive pair collapses to one of five tiers:
\pm,\dots)The overall verdict is the weakest link plus an endpoint gate (did the chain actually reach the target?). And the model's
change_typeis only an advisory claim — SymPy is the judge; a mislabeled step is downgraded one tier.A wrong middle step like
x^2 = 4 → x = 7parses fine, so it used to slip through. Now it's Refuted — and that isn't hypothetical. Even though the model technically "reached" the target we asked for, grounding refuses to bless the bad step:math correctand the endpoint gate both pass — the chain did end atx = 7— but the overall verdict is ✗ Refuted, because reaching the requested target is not the same as every step being valid. The CAS is the judge.And here's a longer one with a genuine spread of tiers — deriving the quadratic formula. Every step is individually grounded or verified, yet the overall verdict is honestly held at 🔹 Plausible because the
∨‑form final state isn't the exact±‑form target we asked for (the endpoint gate, not a weak step):Steps 6–8 carry a disjunction (
∨) — the two roots — and SymPy grounds the square‑root branch and the algebra around it (🥇/🥈) rather than punting. That disjunction support is recent (#375); without it those steps would have shown as ○ Unchecked ("not a single convertible expression").3. How the animation stays stable — rebasing for stable ids
A smooth morph needs to know which glyph is which across two states — the
2inc^2must keep its identity so it glides instead of vanishing and reappearing. We get that by rebasing every state's graph onto the previous one and threading a stable node id through.The rebase is GumTree‑style: anchor the largest identical subtrees first (by a downward subtree signature), recursively align their descendants, then a content‑only fallback for what changed; genuinely new nodes get a fresh id. Render with
to_latex(..., with_ids=True)and every glyph carries\htmlData{n=<id>}. The browser engine then runs a FLIP animation keyed ondata-n:So everything that persists interpolates; only genuinely new pieces fade in and removed pieces fade out. That's the whole trick behind the Manim‑style morph.
4. The agent tool that triggers a derivation
The chat agent can produce a derivation on demand. The user asks in natural language; the agent infers the endpoints and calls a tool that returns a verified animation, identical to clicking a node's "Derive" button.
Because the payload carries the confidence tiers, the agent can't present hand‑waving as proof — an ungrounded step shows up honestly as Unchecked or Refuted rather than a confident‑looking wrong answer.
Where this is going — upcoming improvements
--attempts 1, no judge — so you're seeing the raw baseline.)TL;DR
An LLM proposes the math, a semantic‑graph + SymPy pipeline grounds every step into one of five honest confidence tiers, and a deterministic rebasing renderer animates the whole derivation with stable ids and per‑step badges — all triggerable straight from chat. Ranking confidence was step one; raising it (refinement), talking math into existence (conversational CAS), and turning it into shareable, playable pages are what's next.
Beta Was this translation helpful? Give feedback.
All reactions