ZFLean: Ergonomic ZFC in Lean 4
- ZFLean is a Lean 4 library that models ZFC set theory, providing an accessible foundation with quotient-based extensional semantics.
- The framework introduces a relational calculus with small tactics to automate domain and functionality side-conditions, significantly reducing boilerplate in proofs.
- It defines canonical set-theoretic constructions like Booleans, naturals, and integers, and bridges them to Lean’s native types, exemplified by a currying isomorphism.
Searching arXiv for the specified paper and closely related Lean/ZFC formalization context. Using the arXiv search tool to look up ZFLean and Lean/ZFC formalization papers. ZFLean is a Lean 4 library for doing core mathematics inside a model of ZFC with the ergonomics expected of typed Mathlib developments. It builds on Mathlib’s ZFC model, contributes a relational calculus for sets with rewriting hints and small predictable tactics, provides canonical set-theoretic constructions such as Booleans, naturals, integers, and sums/option, and establishes bridges between ZFC objects and Lean’s native types so that mixed set-level and typed proofs can be carried out within one development. Its stated aim is to reduce boilerplate for extensional reasoning while remaining compatible with vanilla Mathlib, and its central demonstration is a proof of a currying isomorphism theorem formulated entirely at set level (Trélat, 27 Apr 2026).
1. Embedding ZFC inside Lean 4
ZFLean starts from Mathlib’s ZFC model. Pre-sets, written PSet, are generated by a single inductive constructor,
so that every pre-set is represented as a cumulative tree of smaller pre-sets (Trélat, 27 Apr 2026). Extensional equivalence on pre-sets is defined by
Membership is then induced by extensional equivalence:
The actual type of sets, ZFSet, is the quotient PSet/∼, and the usual set-theoretic operations, including , , , and , are lifted along this quotient.
This organization places ordinary set-theoretic reasoning inside a dependently typed assistant without abandoning quotient-based extensional semantics. A plausible implication is that ZFLean is designed for developments that want set-level mathematics in a form close to textbook ZFC while still exploiting Lean 4’s proof infrastructure.
2. Relational calculus and small tactics
A major layer added by ZFLean is a relational calculus on ZFSet. The library defines the identity relation on ,
the converse of ,
0
the composition 1,
2
and the associated notions of domain, range, and image: 3
4
5
In each definition, the side-condition 6 is treated as an implicit hypothesis that the tactic zrel attempts to discharge automatically (Trélat, 27 Apr 2026).
ZFLean distinguishes partial from total functions at the set level. A partial function 7 is functional when
8
and a total function additionally satisfies 9, yielding
0
The tactics zpfun and zfun search the local context, together with closure lemmas tagged by attributes, to solve these goals.
| Tactic | Goal form | Tagged attribute |
|---|---|---|
zrel |
R ⊆ A × B |
@[zrel] |
zpfun |
IsPFunc(f,A,B) |
@[zpfun] |
zfun |
IsFunc(A,B,f) |
@[zfun] |
The library also introduces a set-level 1-abstraction,
2
interpreted as the graph
3
Application 4 is a choice operator returning the unique 5 with 6, under side-conditions IsPFunc(f,A,B) and x∈A, again discharged by zpfun. The associated theorem package includes the specification, extensionality, 7-, and 8-laws: 9
0
1
The significance of this layer is operational rather than foundational: the library hides subset-of-a-product side-conditions and routine well-formedness obligations behind three small tactics. This suggests a proof style in which ordinary set-relational manipulations can be written directly, without constant manual reconstruction of typing side-conditions.
3. Canonical set-theoretic constructions
ZFLean builds canonical versions of several standard datatypes as ZFC objects. For Booleans, it takes
2
and defines ZFBool as the subtype of ZFSet consisting of elements of 3 (Trélat, 27 Apr 2026). It provides ZFBool.casesOn for case analysis together with the usual operations 4, 5, and 6, implemented as operations on ZFBool. The library includes simp theorems such as and_true and and_comm.
For naturals, the object
7
is exposed as the subtype ZFNat. The constructors are
8
and an induction eliminator ZFNat.rec is registered. ZFLean then defines add, mul, pred, and related operations, and equips ZFNat with a commutative semiring so that Lean’s [ring](https://www.emergentmind.com/topics/ring) tactic applies directly. The example
7
is explicitly supported.
For integers, the library defines
9
under the relation 0, yielding a commutative ring. It also carves out a concrete set of representatives 1 and proves it isomorphic to the quotient type. For rationals, it similarly defines
2
under 3, yielding a field.
The library also defines coproducts and option types. For sets 4,
5
with injections inl and inr. Then
6
with constructors none and some, and a corresponding eliminator Option.casesOn.
Taken together, these constructions show that ZFLean does not stop at a bare quotient model of sets. It assembles a usable basis for everyday formal mathematics at set level, including elimination principles and algebraic structure where appropriate.
4. Bridges to Lean’s native types
Every canonical ZFC object introduced by ZFLean is proved isomorphic, in the usual 7 sense, to a native Lean counterpart (Trélat, 27 Apr 2026): 8
9
The library registers coercions so that proofs can move back and forth between the set-theoretic and typed presentations.
A representative example is the Boolean distributivity identity
0
for ZFBool. Rather than reprove it natively at set level, ZFLean transports the standard theorem Bool.and_or_distrib_left across the bridge to Bool, then concludes by Subtype.eq. The practical effect is that typed Mathlib results become immediately reusable in set-level developments.
This bridge mechanism is one of the framework’s defining features. The paper explicitly describes it as enabling mixed set-level/typed proofs. A plausible implication is that ZFLean is intended neither as a rejection of typed mathematics nor as a complete duplication of Mathlib, but as a layer permitting controlled interoperability between a ZFC semantics and Lean’s ordinary type-theoretic library.
5. Extensional proof style and boilerplate reduction
ZFLean emphasizes boilerplate reduction in extensional arguments. Once hypotheses IsFunc A B f and IsFunc A B g are available, the equivalence
1
is proved by expanding both functions into 2-abstractions and rewriting with 3- and extensionality lemmas:
8
The noteworthy point is not the statement itself but the elimination of the associated well-formedness obligations. The paper states that all the membership-in-domain and well-formedness obligations vanish thanks to zfun and the @[zfun] lemmas (Trélat, 27 Apr 2026).
This proof pattern exemplifies the library’s stated goal of lowering the friction of set-theoretic formalization in a dependently typed assistant. The reduction of extensional bookkeeping is central because quotient-based set semantics otherwise tend to produce repetitive domain and functionality side-conditions.
6. Currying isomorphism and overall scope
The running case study is the standard currying isomorphism
4
ZFLean defines set-level curry and uncurry maps:
9
It then proves
0
by applying is_func_ext_iff, unfolding curry and uncurry, using the 5- and 6-laws fapply_lambda and lambda_eta, and rewriting with fapply_composition and fapply_Id until only a reflexive equality remains. From these two lemmas, ZFLean derives an isomorphism using
1
and concludes with
2
(Trélat, 27 Apr 2026)
The case study is intended as a typical use of the framework rather than an isolated result. It exercises the canonical constructions, the relational calculus, the small tactic layer, and the interoperability mechanisms in one proof. The paper reports that, in under 9 000 lines of Lean 4, approximately 700 theorems are used to deliver this environment. This suggests that ZFLean’s contribution is primarily architectural: it packages a quotient-model foundation, a relational proof language, and typed interoperability into a coherent library for set-level mathematics in Lean 4.
A common misunderstanding would be to treat ZFLean as merely a foundational encoding of ZFC. The paper’s emphasis is broader: it presents not only a model of ZFSet = PSet/∼, but also an ergonomic layer for proofs, canonical mathematical constructions, bridges to native datatypes, and compatibility with vanilla Mathlib. Conversely, it should not be conflated with the unrelated acronym “ZOLean” used for zeroth-order LLM fine-tuning (Guo et al., 2024).