Papers
Topics
Authors
Recent
Search
2000 character limit reached

ZFLean: Ergonomic ZFC in Lean 4

Updated 4 July 2026
  • 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,

mk(α:Type u)(A:αPSet):PSet,\mathrm{mk}(\alpha : \mathrm{Type}\ u)(A : \alpha \to \mathrm{PSet}) : \mathrm{PSet},

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

α,Aβ,B        (a,b,A(a)B(b))    (b,a,A(a)B(b)).\langle\alpha,A\rangle \sim \langle\beta,B\rangle\;\iff\; (\forall a,\,\exists b,\,A(a)\sim B(b)) \;\land\; (\forall b,\,\exists a,\,A(a)\sim B(b)).

Membership is then induced by extensional equivalence: xα,A        a,  xA(a).x\in\langle\alpha,A\rangle\;\iff\;\exists a,\;x\sim A(a). The actual type of sets, ZFSet, is the quotient PSet/∼, and the usual set-theoretic operations, including \varnothing, \cup, ×\times, and P\mathcal{P}, 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 AA,

1A    {xA×Aπ1(x)=π2(x)},1_A \;\triangleq\;\{\,x\in A\times A\mid \pi_1(x)=\pi_2(x)\,\},

the converse of RA×BR\subseteq A\times B,

α,Aβ,B        (a,b,A(a)B(b))    (b,a,A(a)B(b)).\langle\alpha,A\rangle \sim \langle\beta,B\rangle\;\iff\; (\forall a,\,\exists b,\,A(a)\sim B(b)) \;\land\; (\forall b,\,\exists a,\,A(a)\sim B(b)).0

the composition α,Aβ,B        (a,b,A(a)B(b))    (b,a,A(a)B(b)).\langle\alpha,A\rangle \sim \langle\beta,B\rangle\;\iff\; (\forall a,\,\exists b,\,A(a)\sim B(b)) \;\land\; (\forall b,\,\exists a,\,A(a)\sim B(b)).1,

α,Aβ,B        (a,b,A(a)B(b))    (b,a,A(a)B(b)).\langle\alpha,A\rangle \sim \langle\beta,B\rangle\;\iff\; (\forall a,\,\exists b,\,A(a)\sim B(b)) \;\land\; (\forall b,\,\exists a,\,A(a)\sim B(b)).2

and the associated notions of domain, range, and image: α,Aβ,B        (a,b,A(a)B(b))    (b,a,A(a)B(b)).\langle\alpha,A\rangle \sim \langle\beta,B\rangle\;\iff\; (\forall a,\,\exists b,\,A(a)\sim B(b)) \;\land\; (\forall b,\,\exists a,\,A(a)\sim B(b)).3

α,Aβ,B        (a,b,A(a)B(b))    (b,a,A(a)B(b)).\langle\alpha,A\rangle \sim \langle\beta,B\rangle\;\iff\; (\forall a,\,\exists b,\,A(a)\sim B(b)) \;\land\; (\forall b,\,\exists a,\,A(a)\sim B(b)).4

α,Aβ,B        (a,b,A(a)B(b))    (b,a,A(a)B(b)).\langle\alpha,A\rangle \sim \langle\beta,B\rangle\;\iff\; (\forall a,\,\exists b,\,A(a)\sim B(b)) \;\land\; (\forall b,\,\exists a,\,A(a)\sim B(b)).5

In each definition, the side-condition α,Aβ,B        (a,b,A(a)B(b))    (b,a,A(a)B(b)).\langle\alpha,A\rangle \sim \langle\beta,B\rangle\;\iff\; (\forall a,\,\exists b,\,A(a)\sim B(b)) \;\land\; (\forall b,\,\exists a,\,A(a)\sim B(b)).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 α,Aβ,B        (a,b,A(a)B(b))    (b,a,A(a)B(b)).\langle\alpha,A\rangle \sim \langle\beta,B\rangle\;\iff\; (\forall a,\,\exists b,\,A(a)\sim B(b)) \;\land\; (\forall b,\,\exists a,\,A(a)\sim B(b)).7 is functional when

α,Aβ,B        (a,b,A(a)B(b))    (b,a,A(a)B(b)).\langle\alpha,A\rangle \sim \langle\beta,B\rangle\;\iff\; (\forall a,\,\exists b,\,A(a)\sim B(b)) \;\land\; (\forall b,\,\exists a,\,A(a)\sim B(b)).8

and a total function additionally satisfies α,Aβ,B        (a,b,A(a)B(b))    (b,a,A(a)B(b)).\langle\alpha,A\rangle \sim \langle\beta,B\rangle\;\iff\; (\forall a,\,\exists b,\,A(a)\sim B(b)) \;\land\; (\forall b,\,\exists a,\,A(a)\sim B(b)).9, yielding

xα,A        a,  xA(a).x\in\langle\alpha,A\rangle\;\iff\;\exists a,\;x\sim A(a).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 xα,A        a,  xA(a).x\in\langle\alpha,A\rangle\;\iff\;\exists a,\;x\sim A(a).1-abstraction,

xα,A        a,  xA(a).x\in\langle\alpha,A\rangle\;\iff\;\exists a,\;x\sim A(a).2

interpreted as the graph

xα,A        a,  xA(a).x\in\langle\alpha,A\rangle\;\iff\;\exists a,\;x\sim A(a).3

Application xα,A        a,  xA(a).x\in\langle\alpha,A\rangle\;\iff\;\exists a,\;x\sim A(a).4 is a choice operator returning the unique xα,A        a,  xA(a).x\in\langle\alpha,A\rangle\;\iff\;\exists a,\;x\sim A(a).5 with xα,A        a,  xA(a).x\in\langle\alpha,A\rangle\;\iff\;\exists a,\;x\sim A(a).6, under side-conditions IsPFunc(f,A,B) and x∈A, again discharged by zpfun. The associated theorem package includes the specification, extensionality, xα,A        a,  xA(a).x\in\langle\alpha,A\rangle\;\iff\;\exists a,\;x\sim A(a).7-, and xα,A        a,  xA(a).x\in\langle\alpha,A\rangle\;\iff\;\exists a,\;x\sim A(a).8-laws: xα,A        a,  xA(a).x\in\langle\alpha,A\rangle\;\iff\;\exists a,\;x\sim A(a).9

\varnothing0

\varnothing1

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

\varnothing2

and defines ZFBool as the subtype of ZFSet consisting of elements of \varnothing3 (Trélat, 27 Apr 2026). It provides ZFBool.casesOn for case analysis together with the usual operations \varnothing4, \varnothing5, and \varnothing6, implemented as operations on ZFBool. The library includes simp theorems such as and_true and and_comm.

For naturals, the object

\varnothing7

is exposed as the subtype ZFNat. The constructors are

\varnothing8

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 ×\times7 is explicitly supported.

For integers, the library defines

\varnothing9

under the relation \cup0, yielding a commutative ring. It also carves out a concrete set of representatives \cup1 and proves it isomorphic to the quotient type. For rationals, it similarly defines

\cup2

under \cup3, yielding a field.

The library also defines coproducts and option types. For sets \cup4,

\cup5

with injections inl and inr. Then

\cup6

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 \cup7 sense, to a native Lean counterpart (Trélat, 27 Apr 2026): \cup8

\cup9

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

×\times0

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

×\times1

is proved by expanding both functions into ×\times2-abstractions and rewriting with ×\times3- and extensionality lemmas: ×\times8 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

×\times4

ZFLean defines set-level curry and uncurry maps: ×\times9 It then proves P\mathcal{P}0 by applying is_func_ext_iff, unfolding curry and uncurry, using the ×\times5- and ×\times6-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 P\mathcal{P}1 and concludes with P\mathcal{P}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).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (2)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to ZFLean.