FormalScience: Scalable Human-in-the-Loop Autoformalisation of Science with Agentic Code Generation in Lean

arXiv cs.AI / 4/28/2026

📰 NewsDeveloper Stack & InfrastructureTools & Practical UsageModels & Research

Key Points

  • The paper introduces FormalScience, a domain-agnostic human-in-the-loop, agentic pipeline that helps experts convert informal scientific/mathematical reasoning into syntactically correct and semantically aligned Lean formal proofs at low economic cost.
  • It demonstrates the approach in physics by building FormalPhysics, a dataset of 200 university-level physics problems and solutions (mostly quantum mechanics and electromagnetism) paired with Lean4 formalizations.
  • The authors evaluate both open-source models and proprietary systems for statement autoformalisation using zero-shot prompting, self-refinement with error feedback, and a new multi-stage agentic method.
  • They provide a systematic analysis of “semantic drift” in physics autoformalisation, identifying issues like notational collapse and abstraction elevation to explain what the formal system verifies when full semantic preservation fails.
  • The work releases a codebase and an interactive UI-based FormalScience system to support autoformalisation and theorem proving in scientific domains beyond physics.

Abstract

Formalising informal mathematical reasoning into formally verifiable code is a significant challenge for large language models. In scientific fields such as physics, domain-specific machinery (\textit{e.g.} Dirac notation, vector calculus) imposes additional formalisation challenges that modern LLMs and agentic approaches have yet to tackle. To aid autoformalisation in scientific domains, we present FormalScience; a domain-agnostic human-in-the-loop agentic pipeline that enables a single domain expert (without deep formal language experience) to produce \textit{syntactically correct} and \textit{semantically aligned} formal proofs of informal reasoning for low economic cost. Applying FormalScience to physics, we construct FormalPhysics, a dataset of 200 university-level (LaTeX) physics problems and solutions (primarily quantum mechanics and electromagnetism), along with their Lean4 formal representations. Compared to existing formal math benchmarks, FormalPhysics achieves perfect formal validity and exhibits greater statement complexity. We evaluate open-source models and proprietary systems on a statement autoformalisation task on our dataset via zero-shot prompting, self-refinement with error feedback, and a novel multi-stage agentic approach, and explore autoformalisation limitations in modern LLM-based approaches. We provide the first systematic characterisation of semantic drift in physics autoformalisation in terms of concepts such as notational collapse and abstraction elevation which reveals what formal language verifies when full semantic preservation is unattainable. We release the codebase together with an interactive UI-based FormalScience system which facilitates autoformalisation and theorem proving in scientific domains beyond physics.https://github.com/jmeadows17/formal-science