https://github.com/ufmg-smite/lean-smt
Tactics for discharging Lean goals into SMT solvers.
https://github.com/ufmg-smite/lean-smt
lean4 smt
Last synced: 3 months ago
JSON representation
Tactics for discharging Lean goals into SMT solvers.
- Host: GitHub
- URL: https://github.com/ufmg-smite/lean-smt
- Owner: ufmg-smite
- License: apache-2.0
- Created: 2021-11-23T20:54:14.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2026-04-05T20:53:28.000Z (3 months ago)
- Last Synced: 2026-04-05T22:23:20.415Z (3 months ago)
- Topics: lean4, smt
- Language: Lean
- Homepage:
- Size: 1.06 MB
- Stars: 273
- Watchers: 8
- Forks: 36
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
- best-of-lean4 - GitHub - 42% open · ⏱️ 18.09.2025): (Packages)
README
# Lean-SMT
This project provides Lean tactics to discharge goals into SMT solvers.
It is under active development and is currently in a beta phase. While it is
usable, it is important to note that there are still some rough edges and
ongoing improvements being made.
## Supported Theories
`lean-smt` currently supports the theories of Uninterpreted Functions and Linear
Integer/Real Arithmetic with quantifiers. Mathlib is required for Real
Arithmetic. Support for the theory of Bitvectors is at an experimental stage.
Support for additional theories is in progress.
## Setup
To use `lean-smt` in your project, add the following lines to your list of
dependencies in `lakefile.toml`:
```toml
[[require]]
name = "smt"
scope = "ufmg-smite"
rev = "main"
```
If your build configuration is in `lakefile.lean`, add the following line to
your dependencies:
```lean
require smt from git "https://github.com/ufmg-smite/lean-smt.git" @ "main"
```
## Usage
`lean-smt` comes with one main tactic, `smt`, that translates the current goal
into an SMT query, sends the query to cvc5, and (if the solver returns `unsat`)
replays cvc5's proof in Lean. cvc5's proofs may contain holes, returned as Lean
goals. You can fill these holes manually or with other tactics. To use the `smt`
tactic, you just need to import the `Smt` library:
```lean
import Smt
example [Nonempty U] {f : U → U → U} {a b c d : U}
(h0 : a = b) (h1 : c = d) (h2 : p1 ∧ True) (h3 : (¬ p1) ∨ (p2 ∧ p3))
(h4 : (¬ p3) ∨ (¬ (f a c = f b d))) : False := by
smt [h0, h1, h2, h3, h4]
```
To use the `smt` tactic on Real arithmetic goals, import `Smt.Real`:
```lean
import Smt
import Smt.Real
example (ε : Real) (h1 : ε > 0) : ε / 2 + ε / 3 + ε / 7 < ε := by
smt [h1]
```
`lean-smt` utilizes
[`lean-auto`](https://github.com/leanprover-community/lean-auto) to monomorphize
goals in dependent type theory and higher-order logic into first-order logic.
Enable auto's monomorphization procedure via `smt +mono`:
```lean
import Smt
variable [Group G]
theorem inverse : ∀ (a : G), a * a⁻¹ = 1 := by
smt +mono [mul_assoc, one_mul, inv_mul_cancel]
theorem identity : ∀ (a : G), a * 1 = a := by
smt +mono [mul_assoc, one_mul, inv_mul_cancel, inverse]
theorem unique_identity : ∀ (e : G), (∀ a, e * a = a) ↔ e = 1 := by
smt +mono [mul_assoc, one_mul, inv_mul_cancel]
```