Skip to main content

FormulaTracer

English | 日本語

From scientific code to auditable mathematics.

Python 3.10+ Rust 1.85+ License: Apache-2.0

FormulaTracer is an experimental, fail-closed semantic auditor for scientific software. It reconstructs mathematical meaning from code, then keeps exact and non-exact relations, assumptions, proof obligations, numerical evidence, provider contracts, provenance, and source localization in one structured workflow. A separately declared theory is optional.

When FormulaTracer cannot justify an interpretation, it reports UNRESOLVED instead of guessing. Structural similarity is not proof, numerical similarity is not a certified bound, and provider retrieval is not verification.

Public references: Python functions · Rust · C ABI · C++ · result/status/evidence · providers · physics · user-defined semantics

Why FormulaTracer?

A formula alone does not say whether the implementation is exact or approximate, which assumptions it needs, where it came from, or which source span caused a divergence. FormulaTracer connects those questions through one Rust-owned semantic model and returns a structured VerificationResult or ReconstructionResult; TeX, JSON, and explanations are derived views.

Typical uses include scientific implementation review, model-change review, pre-publication checks, reproducibility work, and inherited-code assessment.

Install

Python 3.10 or newer is required. Published supported wheels are intended to include the native core, so end users do not need Rust, Cargo, or CMake.

python -m pip install formulatracer

This repository is currently version 0.1.0; package publication is not part of this readiness work. Source developers need Rust 1.85+, and the optional C++ frontend requires LLVM/Clang major 18 and a C++20 build toolchain.

Quick start: audit code without a theory

Clone the repository, install it, then run the synthetic example:

python -m pip install -e .
formulatracer python-audit examples/python_audit/weighted_sum.py --function calculate_weighted_score --output weighted_score --mode REPORT_ONLY --report output/python-audit/report.md --json-output output/python-audit/audit.json --no-lean

The report contains the independently reconstructed implementation expression, numeric backward slice, assumptions, provider contracts, provenance, and any unresolved boundary. No theory annotation is required.

An optional stronger comparison can be added when a theory is available:

from formulatracer import FormulaTracer

formula = FormulaTracer.from_tex(r"\sum_{i=0}^{N-1} x_i")
plan = formula.plan_generation(language="python", search="broad")
print(plan.explain(limit=5))
generated = formula.generate(language="python", auto_select=True)
result = generated.verify()
print(result.status)
print(result.independent_audit)

Candidate similarity only starts an investigation. Selection still requires typed unification, constraints, authorized transformations, and independent re-analysis.

Core workflow

Scientific source -> Implementation IR -> Mathematical reconstruction
  -> Exact/relational analysis -> Assumptions and obligations
  -> Error/range and provider evidence -> Provenance and localization
  -> Structured result -> AuditBundle / TeX / JSON / explanation

Main Python entry points are FormulaTracer.from_source, FormulaTracer.analyze, FormulaTracer.from_tex, plan_generation, reconstruct, and the native structured-result wrappers. See the Python API instead of relying on internal cpp_audit modules.

Supported languages

Language Implementation role Audit input Code generation End-user Python required?
Python Public facade and frontend Yes Yes Yes for Python API/CLI
Rust 2021 Semantic core and native CLI Yes, via current project frontend Yes No for native semantic-document API
C Stable ABI v1 Limited C/C++ frontend path No No
C++17/20 Clang 18 audited input Yes Yes No for C ABI/C++ wrapper
Lean 4.19 Independent proof layer No Proof obligations only No

The FormulaTracer C++ components build as C++20. The native CLI currently operates on semantic documents (canonicalize, tex, compare); it is not a complete Rust-source audit CLI. See language support.

Scientific libraries and providers

Provider contracts cover selected public APIs, not an entire upstream library. Most external library entries are currently REFERENCE_ONLY_VERSION_UNPINNED; therefore this release does not promise a broad NumPy/SciPy/xarray version range. Axis, dtype, missing-value, named- dimension, device, laziness, mutation, and default semantics remain explicit contract conditions. See the provider matrix.

User-defined semantics: a redundant evidence path

@cpp_audit.theory(output=..., expression=...) supplies a user declaration to the same Mathematical IR, relation, evidence, and provenance pipeline used by automatic reconstruction. It is useful for private callbacks, future libraries, hardware kernels, and source that is unavailable to the auditor. It is not a second evaluator and a declaration alone never becomes implementation-, reference-, or Lean-verified evidence.

When implementation-derived mathematics is available, FormulaTracer reports MATCH, MISMATCH, or NOT_EVALUABLE between the two independent paths. Callback value semantics and effects are separate: an expression may be retained while purity remains UNKNOWN_EFFECT. See user-defined semantics.

Physics foundation

The versioned physics foundation defines multivariable/vector calculus, geometric integral relations, dimensions and frames, SO(3)/quaternion representations, Fourier/Laplace relations, numerical realizations, and selected SciPy callback boundaries. Support levels are reported separately as DEFINED, THEOREM_REGISTERED, LEAN_KERNEL_VERIFIED, REALIZATION_AVAILABLE, CONDITIONAL, or PARTIAL.

FormulaTracer audits mathematical and implementation relations. It does not prove that a physical law is empirically true. General Noether, Gauss/Stokes, SE(3), finite-volume error, and AD claims remain conditional unless their listed obligations are discharged. See the physics support boundary.

Platform status

Platform Source/tests Native package Status
Windows x86-64 Locally tested Wheel build and clean-install tested Tested
Linux x86-64 Debian GNU/Linux 12 (bookworm), Python 3.11.2 Wheel/sdist build, clean install, native load, and release suite tested in a real x86-64 Linux container Tested on this recorded environment only
macOS Not validated No release wheel claim Untested

Evidence model

  • KERNEL_VERIFIED: checked by the Lean kernel.
  • KERNEL_VERIFIED_UNDER_ASSUMPTIONS: kernel-checked with listed assumptions.
  • FORMALLY_DERIVED: derived from versioned rules and evidence.
  • REFERENCE_CONTRACT: backed by an upstream public reference.
  • EMPIRICALLY_VALIDATED / RUNTIME_EVIDENCE: tests or a concrete run, not proof.
  • UNRESOLVED: ambiguity, unsupported behavior, missing contract, or open obligation.

Exact equality, approximation, discretization, truncation, sampling, and algorithmic realization are distinct relations. Read proof levels and the trust boundary.

Examples

Non-goals and limitations

FormulaTracer does not prove compilers, CPUs, every external implementation, or a researcher's scientific intent, and is not a general compiler, numerical solver, CAS, Lean replacement, or arbitrary-software verifier. It does not silently infer unknown semantics and does not replace scientific judgement. Complete Rust-source native audit orchestration is not yet exposed by formulatracer-native. Performance is secondary to semantic correctness and fail-closed behavior.

Runtime-only call targets, non-exhaustive dynamic keys, unknown backends, impure/opaque callbacks, and unproved conditional theorems remain partial or unresolved. “Currently unresolved” does not mean “fundamentally impossible”; user contracts, runtime evidence, or provider evidence may close some cases, but those evidence classes are never relabelled as static proof.

Documentation and support

Start with the class and function usage guide (日本語) or the documentation index. Use GitHub Issues for bugs and GitHub Discussions for usage questions. Report vulnerabilities privately as described in SECURITY.md.

Citation, license, and contributing

Citation metadata is in CITATION.cff. FormulaTracer is licensed under Apache-2.0; third-party categories and redistribution notes are in THIRD_PARTY_NOTICES.md. Generated-code licensing depends on user input, selected templates, and upstream provenance; generation does not automatically impose the FormulaTracer project license on all output.

Contributions should preserve fail-closed behavior, add positive/negative/ unresolved tests, and record non-blocking findings in the defect ledger. See CONTRIBUTING.md.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

formulatracer-0.1.0.tar.gz (2.0 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

formulatracer-0.1.0-py3-none-win_amd64.whl (2.0 MB view details)

Uploaded Python 3Windows x86-64

formulatracer-0.1.0-py3-none-manylinux_2_34_x86_64.whl (2.1 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

File details

Details for the file formulatracer-0.1.0.tar.gz.

File metadata

  • Download URL: formulatracer-0.1.0.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for formulatracer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6efb817f6db636f649efdc2e76e115fd4fcaa225ddea104f9a69e1d36d758156
MD5 d2a7ac5cc66f722fe938496101d8f83c
BLAKE2b-256 a92875bb89256c24a0fb6ca540c4c3735c513bd1d24e7b3a4da291ce0cce2786

See more details on using hashes here.

Provenance

The following attestation bundles were made for formulatracer-0.1.0.tar.gz:

Publisher: publish-pypi.yml on 3e456/FormulaTracer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file formulatracer-0.1.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for formulatracer-0.1.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 50596346f4341ae2864508b910dbc612102c4a52eef50b9bf541affaf9765f04
MD5 bb05ee4d82a3c69c3719ccd5158ac83f
BLAKE2b-256 b169deed08957ffb4709001f6d2ab974a3386334c9d4decc065715cb470f719e

See more details on using hashes here.

Provenance

The following attestation bundles were made for formulatracer-0.1.0-py3-none-win_amd64.whl:

Publisher: publish-pypi.yml on 3e456/FormulaTracer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file formulatracer-0.1.0-py3-none-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for formulatracer-0.1.0-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 87301e97aaf7977f5b04dbf8dcb3865171f0f8efc105a0d4b19503d81243e97f
MD5 eaee674756e9903e52e7d27c1430dab9
BLAKE2b-256 32ffdacd0c1eef0046d01e035b6e3b7dbe15393dac4e9d8b089d9d1278ab3810

See more details on using hashes here.

Provenance

The following attestation bundles were made for formulatracer-0.1.0-py3-none-manylinux_2_34_x86_64.whl:

Publisher: publish-pypi.yml on 3e456/FormulaTracer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.1

3 files

This release

0.1.0 This release

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page