ZFLean: a framework for set-level mathematics in Lean

arXiv:2604.24195 · cs.LO · Submitted 2026-04-27 · Read on arXiv

Listen

Radio episode about this paper

Transcript

Introduction to the show: ident: Computer Science. The day in computer science: software, systems and theory on arXiv.

Tom: We're looking at the paper: "ZFLean: a framework for set-level mathematics in Lean".

Jane: Here's the gist of the paper. ZFLean presents ZFLean, a Lean 4 library for doing core mathematics inside Mathlib’s model of ZFC set theory On top of this model, they build a relational calculus for binary relations, partial functions, and total functions and the canonical set-theoretic constructions with their usual algebraic structures.

Tom: This framework is significant because it provides an ergonomic layer for performing set-level reasoning in Lean, bridging the gap between set theory and typed programming.

Jane: Framework Architecture ZFLean is designed around a core relational calculus that handles binary relations and partial/total functions.

Tom: This calculus is automated by four small, bounded tactics named zrel, zpfun, zfun, and zdom which discharge the side conditions generated by these operations.

Title and authors: Tom: So we're looking at this paper called "ZFLean: a framework for set-level mathematics in Lean," and it seems like they're building something specific to how we do math inside Lean, which is usually about typed programming.

Jane: Right. It sounds like they are taking the big model of ZFC set theory that Mathlib uses and putting a layer on top of it so you can do core mathematics right there in Lean without having to constantly switch back and forth between sets and types.

Lu: Yeah, the paper describes this framework around a relational calculus for binary relations, partial functions, and total functions. It’s not just adding new math; it’s building an ergonomic layer so you can do set-level reasoning in Lean.

Meng: Ergonomic is good to hear because I usually find that when you try to mix those two worlds, things get really messy fast and you end up debugging side conditions that have nothing to do with the actual math.

Lalam: Essentially, they’ve automated the side conditions for these operations using four small tactics—zrel, zpfun, zfun, and zdom—which make sure you're dealing with the right kind of object.

Tom: That sounds like a lot of work to build that automation on top of an existing model like Mathlib’s ZFC set theory. What’s the main goal they are trying to achieve with this entire structure?

Jane: The main goal is bridging that gap between abstract set theory and the world of typed programming, making it usable in Lean four for doing core math <ref:2604.24195#pg1>. They do this by exposing canonical constructions like Booleans, naturals, integers, rationals—all with their algebraic structures—and giving them set-level anchors.

Lu: They build these canonical objects with set-level anchors and then provide the typed views of those anchors with the algebraic structure exposed on the views. It’s about having both levels interacting cleanly without one completely replacing the other.

Meng: I’m interested in how they handle things like defining what it means for something to be a relation or a partial function at this set level, because that's where most of my headaches come from when I try to write complex logic.

Lalam: The four tactics mentioned earlier are what discharge those side conditions—being a relation, being a partial function, or belonging to a domain—and the set-theoretic form of definedness. It’s all about managing those constraints automatically so you don't have to worry about them manually every time you define something new.

Title and authors: Tom: And then they have these transfers, which are really interesting because they take a goal written in terms of their set-level objects and rewrite it into the equivalent goal for the native Lean types that Mathlib already understands.

Jane: That transfer tactic is a key part of the design; it restates a goal about those constructions as its equivalent goal about their Mathlib counterpart, where Mathlib’s lemmas and decision procedures actually apply. It lets you use all the existing power of Lean’s established libraries on top of this set-level foundation.

Lu: They focus on using equivalence-based transfer, which is well understood in the context of transport along equivalences between views, tying everything together with a certificatepassing partial-function interface. It's about interoperability being a convenience for the set-level core, not a dependency.

Meng: So if I’m thinking about deploying this kind of system to actually run something—say, some denotational semantics for an imperative language—how does this framework actually help me with the actual execution or verification?

Lalam: The case study they wrote shows exactly that; it uses the tactics and those transfers to do denotational semantics on a small imperative language where stores are treated as set-level objects. Program equivalence is then verified as equality of sets, which is a very concrete way to check things.

Tom: That’s a pretty strong point for practical use because it lets you verify program equivalence at the set level, which is much more robust than just checking some type-level property that might be too abstract.

Jane: It gives you a way to ground those program properties in the actual set-theoretic universe, which is powerful when you're dealing with things like storing state or modeling memory structures.

Lu: They build canonical constructions up to rationals and sums, exposing their algebraic structures on the views, which means you get all the standard math tools right there alongside the set theory definitions. It’s comprehensive for those basic building blocks.

Meng: For me, I wonder how robust this system is when things get more complex than just simple stores and natural numbers; what happens when we introduce more intricate data structures or interactions between those relations?

Lalam: The paper focuses on the core relational calculus and canonical constructions up to rationals, which sets the foundation. Future work suggests they are looking at extending this for the reals, which is a big step.

Tom: And I see they’re hinting that their automation isn't trying to be a general-purpose proof search engine; it’s more of a narrow, bounded closure search over tagged lemmas and local hypotheses rather than general-purpose proof search.

Title and authors: Jane: That makes sense for something this complex; limiting the automation helps keep things predictable and faster for solving specific domain-membership obligations, like checking if an element belongs to a function's domain.

Lu: They stop at weakening and destructuring steps where that closure search stops, which means they aren't trying to solve every single possible proof path, just the ones that are locally tractable under those specific rules. That keeps the complexity manageable for now.

Meng: So it’s not claiming to solve every hard problem in set theory; it’s providing a very fast and reliable way to handle the fundamental operations you'd use constantly in your work.

Lalam: Exactly. It provides the layer, and their case study shows how that layer handles the side conditions when you're modeling something like denotational semantics, where program equivalence boils down to set equality.

Tom: So overall, they’ve built a very focused integration architecture that makes set theory usable within Lean four for doing core mathematics <ref:2604.24195#pg1>. It’s a layer over Mathlib that handles relations and canonical math with bounded automation and transfers to native types.

Jane: And the implication is that we can do set-level reasoning in Lean in a way that feels much more integrated with the rest of the typed programming ecosystem, rather than feeling like a separate, disconnected mathematical toy.

Lu: It’s about making it usable as a common untyped universe where you have these typed views for the algebra, which is what makes it so flexible for integrating with other structures.

Meng: For production work, that means less time spent fighting the type system just to prove some basic set-theoretic property about your data structure; you can rely on this framework to handle those foundational checks automatically.

Lalam: The paper presents ZFLean as a framework for set-level mathematics in Lean, which provides a relational calculus with bounded automation for its side conditions and canonical constructions up to rationals with their algebraic structures.

Tom: It seems like the future work they mentioned is looking at extending this to the reals, which would be a significant move since the reals are often harder to handle than integers or rationals in these kinds of systems.

Jane: And that points toward a bigger picture where they’re trying to push this framework into handling more complex mathematical objects, moving beyond just the basic number systems.

Title and authors: Lu: I think what's really interesting is how they approach the complexity—by focusing on making the core operations manageable through those bounded tactics and then relying on those transfers to handle the translation to native types.

Meng: It’s a pragmatic approach then, focusing on getting a robust, verifiable foundation for the basics first before tackling things that require much deeper search capabilities.

Lalam: The case study evaluation showed that this layer works well in practice for denotational semantics, showing how side conditions are discharged and providing metrics on size and elaboration time.

Tom: It’s encouraging to see those practical results, especially when you look at the size of the library; nine thousand nine hundred fifty-seven lines of code with eight hundred thirty-four theorems already in the modules.

Jane: That scale shows they've built a substantial set of tools, and it gives confidence that this isn't just a toy project but something that can actually be used to build real things.

Lu: The contribution is definitely less about inventing entirely new mathematical objects and more about the integration architecture—the way they tie the set-level core, the untyped universe, and those typed views together. That’s where the real research value lies.

Meng: If you were to deploy this idea to a team, you'd be looking at a solid foundation for verifying program correctness related to data structures defined in set theory without having to reinvent the wheel on the foundational math side.

Lalam: So, in summary, ZFLean is essentially providing that layer—the relational calculus and canonical objects with bounded automation and transfers—to let you do set-level reasoning inside Lean four <ref:2604.24195#pg1>.

Tom: That’s what I’m taking away: a very focused system for handling the foundational math side of things within a typed programming environment. It's solid, it's measurable, and it gets the job done for those core mathematical needs.

Jane: It definitely feels like they are building infrastructure so that complex applications can rely on a set-level foundation without having to manage all those underlying set theory details manually.

Lu: And they’ve clearly laid out the path forward by focusing on extending this into handling the reals, showing ambition beyond just the initial integer and rational constructions.

Meng: It’s about building something that is reliable for what it needs to be right now, and then having a clear plan to expand it when the real-world problems demand more advanced mathematical tools.

Lalam: And that's what makes this paper interesting: they aren't just presenting a collection of theorems; they are presenting an integration architecture that solves the problem of how to do set-level math in Lean.

The paper's summary: Tom: So, ZFLean is basically this new set of tools for Lean that lets you do core mathematics right inside Lean four, using Mathlib's ZFC set theory as the foundation.

Jane: It’s trying to bridge that gap between abstract math and how we actually write typed programs. Basically, they built this relational calculus for things like relations and functions, and they automate the tricky side conditions you usually have to worry about manually.

Lu: The big idea is making it ergonomic so you can do set-level reasoning without constantly switching back and forth between sets and types in a way that gets messy. They expose canonical math objects like naturals or rationals with their algebraic structures, but they keep the view separate from the set-level anchor for now.

Meng: So, if I’m thinking about using this to verify some program logic, it means you can treat the state of my program as a set and perform proofs at that level of abstraction?

Tom: Exactly. And one really important part they include is these transfers—a tactic that takes a goal written in terms of their set-level objects and rewrites it into the equivalent goal for the native Lean types Mathlib already uses. It leverages all those existing lemmas and decision procedures from Mathlib.

Jane: That transfer mechanism is smart because it lets you move your proof work across the boundary, using the established tools from both worlds to solve problems. It’s not just defining things in one place; it’s having a way to check if what you proved at the set level is equivalent to what Mathlib already knows about its types.

Lu: And they did this with a case study on denotational semantics for an imperative language. They showed how the tactics discharge those side conditions, and program equivalence boils down to just checking if the sets of states are equal. That’s a concrete way to verify program correctness.

Meng: So what’s actually important here for someone shipping models? It means you can ground your data structure properties in actual set theory rather than just type-level constraints that feel a bit too abstract.

Tom: Right. And the automation they use isn't trying to be a general proof search engine; it’s focused on being fast and predictable for those specific domain membership obligations, stopping when it hits certain steps like weakening or destructuring. It keeps the complexity under control right now.

Jane: They also mentioned where they are heading, though. They stopped at rationals and integers, but future work is looking at extending this framework to handle the reals and transfer along embeddings instead of just equivalences with native types.

Lu: Extending it to the reals is a big step because dealing with real numbers in these kinds of systems usually brings up much harder convergence issues. It shows they're thinking about pushing this framework into more complex mathematical territory.

Meng: So for now, it’s a solid foundation for the basics—handling relations and basic numbers reliably—but they aren't claiming to solve every hard problem in set theory just yet.

Tom: That’s right. It’s a very focused integration architecture that makes the foundational math usable inside Lean four without you having to manage all those underlying set theory details manually.

Jane: It feels like they’re building infrastructure so that complex applications can rely on a set-level foundation without having to manage all those underlying set theory details yourself.

Lu: The contribution isn't just inventing new mathematical objects; it’s the way they tie the set-level core, that untyped universe, and those typed views together in a flexible way for integration. That’s where the real research value is right now.

Meng: If you were to deploy this idea to a team, you'd be looking at a solid foundation for verifying program correctness related to data structures defined in set theory without having to reinvent the wheel on the foundational math side.

Tom: It’s about building something that is reliable for what it needs to be right now, and then having a clear plan to expand it when the real-world problems demand more advanced mathematical tools.

Jane: And that’s what makes this paper interesting: they aren't just presenting a collection of theorems; they are presenting an integration architecture that solves the problem of how to do set-level math in Lean.

Meng: So, in summary, ZFLean provides that layer—the relational calculus and canonical objects with bounded automation and transfers—to let you do set-level reasoning inside Lean four.

The paper's improvements: Tom: So, ZFLean isn't just about getting things running; the authors are pointing out where they can improve the automation layer of that relational calculus.

Jane: They admitted that their current automation is a narrow, bounded closure search over tagged lemmas and local hypotheses rather than trying to be a general proof search engine.

Lu: That means it stops at weakening and destructuring steps where that closure search stops, which keeps things predictable for those specific domain membership checks like checking if something is in the domain of a function.

Meng: So what’s the next move then? How do you get past that stopping point when you need to prove something more complex than just a simple membership check?

Tom: The future work they mentioned is specifically focusing on automating those stopping steps and also looking at transfer along embeddings instead of just equivalences with native types.

Jane: Transferring along embeddings sounds like it would let you move proofs between the set-level core and the host’s types even when they aren't perfectly equivalent, which opens up more possibilities for using existing Mathlib lemmas.

Lu: I see that as a way to handle situations where your set-level object isn't exactly what the native type represents, but there is still some underlying structure you can use to make the connection. It’s about making those boundaries a little bit softer for more advanced proofs.

Meng: If it gets better at handling embeddings, does that mean we can start modeling things that are structurally similar but not identical in a more robust way?

Tom: That’s right. It suggests they’re moving from just checking if two things are equivalent to checking if one thing is embeddable into the other. That's a step up in complexity for the automation.

Jane: It moves the goal from perfect translation to finding a valid structural relationship, which is much more useful when you’re dealing with complex data structures where you can't always guarantee exact equality between views and types.

Lu: They aren't trying to build a universal proof engine; they are refining the specific search strategy for their domain, which is a very pragmatic way to tackle the automation challenge without getting bogged down in infinite search space.

Meng: Pragmatic is good when you’re shipping code; I don't need an infinitely searching system, I need something that reliably handles the ninety percent of cases where my data structure property holds true.

Tom: Exactly. And they are focused on making the existing tools more useful for those common tasks before trying to build a massive general-purpose solver.

Jane: So what does this mean for someone just using ZFLean today? It means the current version is very reliable for handling those basic set-theoretic operations and getting you into the world of typed programming semantics without constant headaches.

Lu: It provides a stable interface where you can focus on the higher-level mathematical reasoning while letting these bounded tactics handle the heavy lifting of side condition management.

Meng: So it’s about keeping the complexity manageable for production workloads right now, and then having a clear plan to expand it when we need that deeper search capability.

Tom: That’s the path they’re on; reliable foundation first, expansion later. And I'm still curious how fast they can actually implement those new stopping step automations when you look at their current codebase size—nine thousand nine hundred fifty-seven lines of code already.

Conclusion: Tom: So to wrap up, ZFLean is essentially this new framework for set-level mathematics in Lean that lets you do core math inside Lean four using Mathlib’s ZFC model with a relational calculus and bounded automation.

Jane: It provides a way to bridge the gap between abstract set theory and typed programming by giving you these canonical objects with their algebraic structures and transfers to native types.

Lu: The core idea is creating an ergonomic layer where you can do set-level reasoning without constantly switching back and forth between sets and types.

Meng: So, for someone shipping models, it means you can ground your data structure properties in actual set theory rather than just type-level constraints that feel a bit too abstract.

Lalam: I’m pretty sure this paper is very solid on the integration architecture—the way they tie the untyped universe and those typed views together is what makes it useful for people building things.

Tom: That’s right, and their case study showed how that layer works in practice for denotational semantics where program equivalence boils down to set equality.

Jane: It’s encouraging to see those practical results, especially when you look at the size of the library; nine thousand nine hundred fifty-seven lines of code with eight hundred thirty-four theorems already in the modules.

Lu: The contribution is definitely less about inventing entirely new mathematical objects and more about that integration architecture—the way they tie everything together.

Meng: If you were to deploy this idea to a team, you'd be looking at a solid foundation for verifying program correctness related to data structures defined in set theory without having to reinvent the wheel on the foundational math side.

Tom: It’s about building something that is reliable for what it needs to be right now, and then having a clear plan to expand it when the real-world problems demand more advanced mathematical tools.

Jane: And that’s what makes this paper interesting: they aren't just presenting a collection of theorems; they are presenting an integration architecture that solves the problem of how to do set-level math in Lean.

Lu: They showed promising work with the reals and transfer along embeddings, which means they’re pushing this framework into handling more complex mathematical territory beyond just basic numbers.

Meng: It’s about building something that is reliable for what it needs to be right now, and then having a clear plan to expand it when we need that deeper search capability.

Lalam: I'm pretty sure this paper is very solid on the integration architecture—the way they tie everything together is what makes it useful for people building things.

Tom: So overall, ZFLean is providing that layer—the relational calculus and canonical objects with bounded automation and transfers—to let you do set-level reasoning inside Lean four.

Jane: It definitely feels like they are building infrastructure so that complex applications can rely on a set-level foundation without having to manage all those underlying set theory details manually.

Lu: They have clearly laid out the path forward by focusing on extending this into handling the reals, showing ambition beyond just the initial integer and rational constructions.

Meng: It’s about building something that is reliable for what it needs to be right now, and then having a clear plan to expand it when we need more advanced mathematical tools.

Université de Lorraine · CNRS · inria · Télécom Nancy

cs.LO

Submitted: 2026-04-27

Updated: 2026-11-12

Project page: https://leanprover-community.github.io/mathlib4_docs/Mathlib/SetTheory/ZFC/Basic.html

License: http://creativecommons.org/licenses/by/4.0/

Importance score: 91/100

The gist: ZFLean presents ZFLean, a Lean 4 library for doing core mathematics inside Mathlib’s model of ZFC set theory On top of this model, they build a relational calculus for binary relations…

Key concepts

Relational Calculus
This is the core system ZFLean uses to handle binary relations, partial functions, and total functions within the set-theoretic model. It allows users to reason about these mathematical structures directly at the level of sets before translating them into Lean types.
Canonical Constructions
ZFLean builds fundamental ZFC objects like naturals, integers, and rationals. These objects come equipped with their set-level anchors, algebraic structures, and automation hooks that make them usable within the Lean programming environment.
Transfers to Native Types
This feature allows proofs written in ZFLean's set-level language to be translated into equivalent goals for native Lean types. A 'transfer tactic' rewrites a goal about a set-theoretic object into an equivalent goal about its corresponding Lean counterpart, enabling the use of Mathlib's existing lemmas.

Terminology

Summary

ZFLean presents ZFLean, a Lean 4 library for doing core mathematics inside Mathlib’s model of ZFC set theory On top of this model, they build a relational calculus for binary relations, partial functions, and total functions and the canonical set-theoretic constructions with their usual algebraic structures. p. 0

Where the paper says it

fr Matteo Pouillat Télécom Nancy, Université de Lorraine Nancy, France Abstract We present ZFLean, a Lean 4 library for doing core mathematics inside Mathlib’s model of ZFC set theory. On top of this model, we build a relational calculus for binary relations, partial functions, and total functions, and the canonical set-theoretic constructions (Booleans, naturals, integers, rationals, sums, and options) with their usual algebraic structures.

This framework is significant because it provides an ergonomic layer for performing set-level reasoning in Lean, bridging the gap between set theory and typed programming. p. 0
Where the paper says it

Mathlib’s own model of ZFC has served mostly for metatheory (Han and van Doorn’s forcing construction and their independence proof for the continuum hypothesis [13, 14]) rather than as an environment for developing set-level mathematics. We therefore build on Lean’s Mathlib [36] and the model of ZFC it provides, and develop ZFLean, a framework for doing mathematics in Mathlib’s model of ZFC with the ergonomics Lean users expect from typed Mathlib developments: notations, rewriting, automation, tactics, and typeclass-driven algebra.

Framework Architecture

ZFLean is designed around a core relational calculus that handles binary relations and partial/total functions. This calculus is automated by four small, bounded tactics named zrel, zpfun, zfun, and zdom which discharge the side conditions generated by these operations. p. 3

Where the paper says it

Automation tactics discharge the wellformedness side conditions these operations carry, so that the objects can be manipulated directly, much as in a paper proof. These tactics are named zrel, zpfun, zfun, and zdom, and Section 3.

The design adheres to conventions where objects are formed in the set-theoretic universe and typed views are interfaces rather than replacements. p. 2
Where the paper says it

Three design conventions govern the development and are referred to throughout. First, objects are formed in the set-theoretic universe, and typed views are interfaces rather than replacements; Section 4 states, per object, the set-level anchor.

Canonical Constructions

The library builds canonical ZFC objects such as Booleans, naturals, integers, rationals, sums, and options. These constructions are exposed through Lean types like ZFNat and ZFInt which have set-level anchors. p. 1

Where the paper says it

CPP ’27, January 2027, Mexico Vincent Trélat and Matteo Pouillat their Lean counterparts, and a transfer tactic that restates a goal about these constructions as its equivalent goal about their Lean counterpart, where Mathlib’s lemmas and decision procedures apply. The transfers are part of the design, but ZFLean is intended first as a set-level proving environment: every canonical construction has an explicit set-level anchor, refinement and quotient types provide typed views of these anchors with the algebraic structure exposed on the views (Table 1), and interoperability is a convenience rather than a dependency for the set-level core.

The canonical objects come with their set-level anchor, typed interface, eliminators, algebraic instances, and automation hooks with transfers that make them usable inside Lean. p. 5
Where the paper says it

4 Canonical Constructions and Universal Properties On top of the relational calculus of Section 3, we build a library of canonical ZFC objects (Booleans, naturals, integers, rationals, sums, and options) and expose their characteristic properties in a form usable in practice. The constructions themselves are textbook (we follow Kunen [18] and claim no mathematical novelty); the contribution is their packaging: each object comes with its set-level anchor, its typed interface, and the eliminators, algebraic instances, and automation hooks with transfers that make them usable inside Lean.

Transfers to Native Types

ZFLean includes transfers across the set/type boundary to Lean types such as ZFNat ≃+∗ Nat and ZFRat ≃+∗ Rat. These transfers restate a goal about these objects as its equivalent goal about their Lean counterpart, where Mathlib’s lemmas and decision procedures apply. p. 0

Where the paper says it

A thin typed layer of refinement and quotient types over the set-theoretic universe lets Lean’s rewriting, type classes, and algebra tactics apply to the typed views of set-level objects. Transfers to Lean’s native types restate a goal about these objects as the equivalent goal about their Mathlib counterpart, where Mathlib’s lemmas and decision procedures apply.

The transfer tactic rewrites the goal about one type into the equivalent goal about another and runs tactics on it. p. 8
Where the paper says it

The transfer for the rationals is obtained from the cast Rat → ZFRat, a ring morphism that is injective because ZFRat has characteristic zero and surjective because every class [(𝑎, 𝑏)]∼ℚ is the quotient of the images of two integers. Such an isomorphism lets us transport statements and proofs across the boundary, and the library packages the transport as a tactic: transfer 𝛼 → 𝛽 ⇒ tacs rewrites the goal about 𝛼 into the equivalent goal about 𝛽 and runs tacs on it.

Case Study Evaluation

A case study written as a client of the library, a denotational semantics of a small imperative language on set-level stores, exercises the tactics and the transfers. The evaluation reports which side conditions the tactics discharge and provides metrics on size and elaboration time. p. 1

Where the paper says it

Section 5 formalizes embeddings and isomorphisms, including the Cantor– Schröder–Bernstein theorem, and presents the transfers to Lean types with the transfer tactic. Section 6 evaluates the library on a case study written as a client of it, a denotational semantics on set-level stores, and reports which side conditions the tactics discharge, the size and elaboration time of the artifact, and its limitations.

The total size of the library is 9,957 lines of code with 834 theorems in the modules of Table 3. p. 9
Where the paper says it

The assignment 𝑥 ∶= 𝑥 + 1 increases the value of 𝑥 (assign_incr): the proof unfolds the abstraction, reads the value off the denotation of the sum, and is left with 𝑛 < 𝑛 + 1 in ZFNat, which transfer ZFNat → ℕ ⇒ omega closes. The development, a separate build target that imports the library as a downstream project would, is 457 lines and 63 theorems; its 204-line prelude adds what the library lacked (domain restriction, override, disjoint unions of partial functions, the loop operator) with closure lemmas tagged for the tactics of Section 3.

Limitations and Future Work

The automation is described as a narrow, bounded closure search over tagged lemmas rather than general-purpose proof search. The library stops at weakening and destructuring steps where the closure search stops. p. 9

Where the paper says it

The manual proof is the assignment case: its abstraction is a partial function on Dom([[𝑒]]) where the goal asks for one on Store(𝑉 ), and the closure search has no weakening rule; one application of pfunc_weaken supplies the step. To isolate what the tagged rules contribute, the lower half of Table 2 reruns the same 30 obligations under plain solve_by_elim with local hypotheses only, under the library’s seeds with every client-tagged rule erased, and in the release environment.

Future work includes automation for these stopping steps and transfer along embeddings rather than equivalences. p. 1
Where the paper says it

The transfers are part of the design, but ZFLean is intended first as a set-level proving environment: every canonical construction has an explicit set-level anchor, refinement and quotient types provide typed views of these anchors with the algebraic structure exposed on the views (Table 1), and interoperability is a convenience rather than a dependency for the set-level core. The individual ingredients are standard: the constructions are textbook, the search engine behind the tactics is solve_by_elim, and transport along equivalences is well understood.

Related Work Context

ZFLean positions its contributions with respect to set-theoretic developments in interactive provers such as Isabelle, Rocq, Mizar, and Metamath. It differs by combining a rewriting-friendly relational calculus, structural side-condition automation, and explicit transfers to the host’s typed libraries. p. 0

Where the paper says it

The aim is not to replace Mathlib’s native arithmetic or data types. ZFLean contributes the following: • a relational calculus: converse, identity, composition, domain, range, and images, together with their interaction laws and rewriting hints feeding four small tactics that automatically discharge well-formedness and domainmembership side conditions; • canonical constructions and usual properties: 𝔹, ℕ, ℤ, ℚ, functions, sums, and options; • transfers across the set/type boundary: equivalences that carry the algebraic structure of these constructions to 1 arXiv:2604.

The transfer tactic is narrower than those in other works because it relates the typed views over ZFSet to the host’s types along equivalences only. p. 8
Where the paper says it

Raw ZFSet propositions such as 𝑥 ∈ 𝐴 and the function spaces 𝐵 𝐴 of Section 3 are outside it; the direction is always the one written in the invocation, and failure is visible, as a residual goal that still mentions the source type. The relation lemmas are also oriented, from the typed views toward Mathlib’s types: the tactic accepts the inverse isomorphism, and Mathlib’s lemmas carry the ring operations along it, but an order relation would need its lemmas restated for that direction.

Conclusion

The paper presents ZFLean, a Lean 4 library for set-level mathematics on top of Mathlib’s ZFC model. It offers a relational calculus with bounded automation for its side conditions, canonical constructions up to Q with their algebraic structures and set-level anchors, and transfers to native types. p. 0

Where the paper says it

The aim is not to replace Mathlib’s native arithmetic or data types. ZFLean contributes the following: • a relational calculus: converse, identity, composition, domain, range, and images, together with their interaction laws and rewriting hints feeding four small tactics that automatically discharge well-formedness and domainmembership side conditions; • canonical constructions and usual properties: 𝔹, ℕ, ℤ, ℚ, functions, sums, and options; • transfers across the set/type boundary: equivalences that carry the algebraic structure of these constructions to 1 arXiv:2604.

A denotational semantics written as a client shows the layer at work: side conditions discharged by the tactics, definedness as domain membership, program equivalence as equality of sets. p. 0
Where the paper says it

Transfers to Lean’s native types restate a goal about these objects as the equivalent goal about their Mathlib counterpart, where Mathlib’s lemmas and decision procedures apply. A case study written as a client of the library, a denotational semantics of a small imperative language on set-level stores, exercises the tactics and the transfers: definedness is a theorem about domains, determinism a partial-functionality proof, and program equivalence an equality of sets.

The future work focuses on the reals and transfer along embeddings. p. 1
Where the paper says it

The individual ingredients are standard: the constructions are textbook, the search engine behind the tactics is solve_by_elim, and transport along equivalences is well understood. The contribution is the integration architecture that makes them one usable layer, a common untyped universe, typed views for the algebra, and equivalence-based transfer, tied together by the certificatepassing partial-function interface.

Green — the paper says it, and the page is printed. Red — no passage carries it, so treat that sentence as unverified. The same check runs on your own text: check a summary against its source, $5.

Improvements for AI systems

  1. Refinement of proof search through bounded closure search: The automation layer uses a narrow, bounded closure search over tagged lemmas and local hypotheses rather than general-purpose proof search, which stops at weakening and destructuring. This makes the system more predictable and faster for solving domain-membership obligations like x in Dom(f).

  2. Integration of set-level mathematical reasoning into functional programming semantics: The system can perform denotational semantics on imperative languages by interpreting stores as partial functions from a set of variables to natural numbers, allowing verification of program equivalence as equalities of sets.

  3. Cross-boundary goal transformation via explicit transfers: The library provides a transfer tactic that restates a goal about these constructions as its equivalent goal about their Lean counterpart, which allows proofs to be moved between the set-level core and native Lean types, leveraging Mathlib's lemmas and decision procedures.

Abstract

We present ZFLean, a Lean 4 library for doing core mathematics inside a model of ZFC with the ergonomics expected of typed Mathlib developments. Building on Mathlib's ZFC model, we contribute a relational calculus for sets with rewriting hints and small predictable tactics, canonical set-theoretic constructions -- Booleans, naturals, integers, sums/option -- and bridges between ZFC objects and Lean's native types enabling mixed set-level/typed proofs. The layer reduces boilerplate for extensional reasoning while remaining compatible with vanilla Mathlib. We discuss library organization and usage patterns that lower the friction of set-theoretic formalization in a dependently typed assistant. We demonstrate typical use of the framework with a case study exercising our constructions and relational calculus through a proof of an isomorphism theorem on curried functions.

Related papers