[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"ga5Gjd2wYP":3},"# LeanCert\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)\n[![Documentation](https://img.shields.io/badge/docs-leancert.io-brightgreen.svg)](https://docs.leancert.io)\n\n**Numerical computation produces suggestions. LeanCert produces theorems.**\n\nLeanCert is a Lean 4 library for certified numerical reasoning. It provides proof-producing tactics and certificate APIs for interval bounds, global optimization, root existence and uniqueness, integration bounds, Chebyshev function certificates, analytic-number-theory finite certificates, exact q-product/product-integral certificates, and neural-network interval verification.\n\n## What LeanCert Provides\n\n* Verified interval bounds for real-valued expressions\n* Proof automation for inequalities over intervals\n* Root existence and uniqueness tactics\n* Global minimum and maximum certificates\n* Definite integral bound certificates\n* Dyadic and rational arithmetic backends\n* Chebyshev `ψ` and `θ` finite-range certificates\n* Analytic-number-theory certificates for Abel transforms, Euler products, Dirichlet truncations, Mertens-style sums, and asymptotic envelopes\n* Exact q-product/product-integral certificates and prime-limit sandwich bounds\n* Neural-network and transformer interval verification tools\n* Lean-only workflows, with Python and bridge tooling split into separate repositories\n\n## Installation\n\nAdd LeanCert to your `lakefile.toml`:\n\n```toml\n[[require]]\nname = \"leancert\"\ngit = \"https://github.com/alerad/leancert\"\nrev = \"main\"\n```\n\nThen run:\n\n```bash\nlake update\n```\n\nLeanCert targets the Lean/mathlib version pinned by `lean-toolchain`.\n\nTo check compatibility in a larger project:\n\n```bash\nlake exe check-compat\n```\n\n## Quick Start\n\nProve a simple bound over an interval:\n\n```lean\nimport LeanCert.Tactic.IntervalAuto\n\nexample : forall x in Set.Icc (0 : Real) 1, Real.exp x \u003C= 3 := by\n  certify_bound\n```\n\nUse a larger Taylor depth for tighter transcendental bounds:\n\n```lean\nimport LeanCert.Tactic.IntervalAuto\n\nexample : forall x in Set.Icc (0 : Real) 1, Real.exp x \u003C= 2.72 := by\n  certify_bound 20\n```\n\nUse the dyadic backend for faster verification on deeper expressions:\n\n```lean\nimport LeanCert.Tactic.DyadicAuto\n\nexample : forall x in Set.Icc (0 : Real) 1,\n    Real.cos (Real.sin (Real.cos x)) \u003C= 1 := by\n  certify_kernel\n```\n\n## Discovery Workflow\n\nLeanCert includes editor commands for exploring bounds before committing to a theorem.\n\n```lean\nimport LeanCert.Discovery.Commands\n\n#bounds (fun x => x^2 + Real.sin x) on [0, 1]\n#find_min (fun x => x^2 + Real.sin x) on [0, 1]\n#find_max (fun x => Real.exp x - x^2) on [0, 1]\n```\n\nThen turn the discovered estimate into a Lean theorem:\n\n```lean\nimport LeanCert.Tactic.IntervalAuto\n\nexample : forall x in Set.Icc (0 : Real) 1,\n    x^2 + Real.sin x \u003C= 2 := by\n  certify_bound\n```\n\n## Root Finding\n\nProve that a root exists:\n\n```lean\nimport LeanCert.Tactic.Discovery\n\nexample : exists x in Set.Icc (1 : Real) 2, x^2 - 2 = 0 := by\n  interval_roots\n```\n\nProve uniqueness using Newton contraction:\n\n```lean\nimport LeanCert.Tactic.Discovery\n\nexample : exists! x in Set.Icc (1 : Real) 2, x^2 - 2 = 0 := by\n  interval_unique_root\n```\n\n## Choosing a Tactic\n\n| Goal                                       | Tactic                 |\n| ------------------------------------------ | ---------------------- |\n| `forall x in I, f x \u003C= c`                  | `certify_bound`        |\n| `forall x in I, c \u003C= f x`                  | `certify_bound`        |\n| Kernel-oriented dyadic bound               | `certify_kernel`       |\n| Multivariate bound                         | `multivariate_bound`   |\n| Root existence                             | `interval_roots`       |\n| Root uniqueness                            | `interval_unique_root` |\n| No roots on an interval                    | `root_bound`           |\n| Point inequality, such as `Real.pi \u003C 3.15` | `interval_decide`      |\n| Counterexample search                      | `interval_refute`      |\n| Minimum certificate                        | `interval_minimize`    |\n| Maximum certificate                        | `interval_maximize`    |\n| Integral bound                             | `interval_integrate`   |\n| Expand finite sums                         | `finsum_expand`        |\n| Simplify vector indexing                   | `vec_simp`             |\n\nSee the full tactics guide in the documentation for examples and troubleshooting.\n\n## Certificate APIs\n\nLeanCert also exposes domain-specific certificate APIs for more structured proofs.\n\n### Chebyshev Certificates\n\n```lean\nimport LeanCert.Engine.ChebyshevPsi\nimport LeanCert.Engine.ChebyshevTheta\n```\n\nThese modules certify finite-range bounds for the Chebyshev functions `ψ` and `θ`.\n\nExample:\n\n```lean\nimport LeanCert.Engine.ChebyshevPsi\n\nopen Chebyshev (psi)\nopen LeanCert.Engine.ChebyshevPsi\n\nexample :\n    forall N : Nat, 0 \u003C N -> N \u003C= 20 ->\n      psi (N : Real) \u003C= (3 : Real) * N := by\n  exact verify_all_psi_le_mul 20 20 3 (by native_decide)\n```\n\n### Analytic Number Theory Certificates\n\n```lean\nimport LeanCert.ANT\nimport LeanCert.ANT.Asymp\n```\n\nThe ANT layer includes finite certificates for:\n\n* step sums\n* Abel transforms\n* Euler and log products\n* Dirichlet truncations\n* harmonic and prime harmonic sums\n* Mertens-style prime sums\n* asymptotic main-term/error envelopes\n* Stieltjes-Abel and Dirichlet-hyperbola transforms\n\n### QProduct Certificates\n\n```lean\nimport LeanCert.QProduct\n```\n\n`LeanCert.QProduct` certifies exact finite product integrals of the form\n\n```text\nF S = ∫ u in 0..1, ∏ n ∈ S, (1 - u^n)\n```\n\nby expanding the product into a signed polynomial and integrating exactly over `ℚ`.\n\nExample:\n\n```lean\nimport LeanCert.QProduct\n\nopen LeanCert.QProduct\n\nexample : finiteIntegralRat ({2, 3} : Finset Nat) = 7 / 12 := by\n  native_decide\n\nexample : F ({2, 3} : Finset Nat) = ((7 / 12 : Rat) : Real) := by\n  rw [finiteIntegralRat_correct]\n  have h : finiteIntegralRat ({2, 3} : Finset Nat) = 7 / 12 := by\n    native_decide\n  exact_mod_cast h\n```\n\nThe q-product module also includes prime-indexed limit certificates, including the formal theorem:\n\n```lean\nprimeLambda_gt_half : (1 : Real) / 2 \u003C primeLambda\n```\n\n## Neural Network Verification\n\n```lean\nimport LeanCert.ML.Network\n```\n\nLeanCert includes verified interval propagation and DeepPoly-style relaxations for machine-learning models.\n\nSupported components include:\n\n* dense feedforward layers\n* ReLU and sigmoid activations\n* GELU\n* transformer attention\n* layer normalization\n* residual connections\n* affine arithmetic for tighter layer-normalization bounds\n* optimized interval propagation backends\n\nThe ML modules are intended for robustness, safety, and model-equivalence verification workflows.\n\n## Architecture\n\nLeanCert follows a certificate-driven architecture:\n\n1. Reify a mathematical expression into `LeanCert.Core.Expr`, or use tactic-level native syntax.\n2. Run a computable checker using rational, dyadic, affine, or domain-specific arithmetic.\n3. Apply a Golden Theorem that lifts the successful check to a semantic theorem over real numbers.\n4. Finish with a short Lean proof script.\n\nIn simplified form:\n\n```text\ncomputable certificate data\n+ boolean or exact checker\n+ Golden Theorem\n= theorem over Real\n```\n\nThis design keeps computation executable while the final claim remains a Lean theorem.\n\n## Verification Status\n\nMost core LeanCert components are fully verified, including:\n\n* fundamental interval arithmetic\n* bounds for `exp`, `sin`, `cos`, `log`, `sqrt`, `atan`, `atanh`, `erf`, and related functions\n* Taylor-model correctness\n* automatic differentiation soundness\n* global optimization certificates\n* root existence and uniqueness certificates\n* rational and dyadic integration certificates\n* dyadic interval evaluation\n* neural-network interval propagation soundness\n* Chebyshev, ANT, and q-product certificate bridges\n\nThe documentation contains a detailed verification-status page, including any known proof gaps.\n\n## Documentation\n\nThe full documentation is available at:\n\n```text\nhttps://docs.leancert.io\n```\n\nUseful starting points:\n\n* Quickstart\n* Choosing Tactics\n* Tactics Reference\n* Discovery Mode\n* Troubleshooting\n* Certificate Overview\n* Golden Theorems\n* Verification Status\n* Neural Network Verification\n\n## Repository Split\n\nThis repository is Lean-only.\n\nThe Python SDK and bridge binaries live in separate repositories:\n\n* Python SDK: `https://github.com/alerad/leancert-python`\n* Bridge binaries / JSON-RPC executable: `https://github.com/alerad/leancert-bridge`\n\n## License\n\nApache 2.0. See [`LICENSE`](LICENSE).\n",1780846761457]