Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsJul 13, 2026·3 min de lecture

Lean 4 — Theorem Prover and Functional Programming Language

Lean 4 is both a programming language and an interactive theorem prover, enabling mathematically verified software and formalized proofs in a single environment.

Prêt pour agents

Installation avec revue préalable

Cet actif nécessite une revue. Le prompt copié demande un dry-run, affiche les écritures, puis continue seulement après confirmation.

Needs Confirmation · 64/100Policy : confirmer
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Lean 4 Overview
Commande avec revue préalable
npx -y tokrepo@latest install 12d61c2b-7ef8-11f1-9bc6-00163e2b0d79 --target codex

Dry-run d'abord, confirmez les écritures, puis lancez cette commande.

Introduction

Lean 4 is a functional programming language and interactive theorem prover developed at Microsoft Research and Carnegie Mellon University. It lets developers write ordinary programs and formal mathematical proofs in the same language, making it a tool for both verified software and research-level mathematics.

What Lean 4 Does

  • Provides a dependent type system for expressing and verifying complex properties
  • Supports writing executable programs alongside machine-checked proofs
  • Includes a tactic framework for interactive proof construction
  • Compiles to efficient native code via C intermediate representation
  • Powers the Mathlib library with hundreds of thousands of formalized theorems

Architecture Overview

Lean 4 is implemented in Lean itself (self-hosted). The compiler type-checks source code against a dependent type theory kernel, ensuring logical consistency. Code that passes the type checker is compiled to C for native execution. The tactic framework allows users to build proofs step-by-step, with the kernel verifying each step.

Self-Hosting & Configuration

  • Install via elan, the Lean version manager
  • Manage projects and dependencies with lake, the built-in build system
  • Configure dependencies in lakefile.lean or lakefile.toml
  • Use VS Code with the Lean 4 extension for interactive development
  • Pin toolchain versions in lean-toolchain file per project

Key Features

  • Dependent types enabling proofs as programs and programs as proofs
  • Powerful metaprogramming and custom tactic authoring
  • Mathlib: one of the largest libraries of formalized mathematics
  • Efficient compiled execution for non-proof code
  • Interactive feedback in editors with goal state display

Comparison with Similar Tools

  • Coq (Rocq) — Coq has a longer history and different tactic language; Lean 4 offers a more modern syntax and self-hosted compiler
  • Agda — Agda focuses on dependently typed programming; Lean 4 adds a richer tactic framework for proof automation
  • Haskell — Haskell has a powerful type system but cannot verify arbitrary properties; Lean 4 can
  • Idris 2 — Idris targets practical dependently typed programming; Lean 4 covers both proofs and practical code
  • F* — F* targets verified security code; Lean 4 is more general-purpose for both math and programs

FAQ

Q: Is Lean 4 only for mathematicians? A: No. Lean 4 is a general-purpose functional language. You can write regular programs without proofs, or combine both.

Q: What is Mathlib? A: Mathlib is a community-maintained library of formalized mathematics in Lean 4, covering algebra, analysis, topology, and more.

Q: Can Lean 4 produce fast executables? A: Yes. Lean 4 compiles to C and produces native binaries with performance suitable for practical applications.

Q: How does Lean 4 relate to Lean 3? A: Lean 4 is a complete rewrite with a new compiler, build system, and syntax. It is not backward-compatible with Lean 3.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires