Hola! I'm Pepa. I make mathematics compile

Mathematician working as a researcher at Basotek while doing a MSc in Formal Methods. I formalize mathematics in Lean 4 and co-organize MadLean, Madrid's Lean community.

MathematicsComputer ScienceFormal MethodsLean 4Autoformalization
Pepa Montero
me.jpg

section About

How I got here

I always knew I wanted to study mathematics. I have been a logic puzzle and sudoku lover for as long as I can remember, and my biggest childhood hero was Professor Layton (I adored those games). Programming came early too: my dad is a programmer and introduced me to it when I was a kid, first through games like Kodu and Project Spark, and later through C. Games have been a big part of how I learn.

I started the Mathematics degree at Complutense University of Madrid in 2019. From 2022 to 2023 I studied abroad at the University of Münster (Germany), where a course on logic programming introduced me to Prolog. It turned out I was good at it, and my interest in programming came right back. I decided to specialize in Computer Science.

In September 2023 I attended the bachelor's thesis defense of a (brilliant) friend of mine, who had set out to prove the independence of the axiom of parallels in Euclidean geometry from Hilbert's axioms, in Lean 3. It was love at first sight. He only briefly explained how Lean works, but the idea of writing mathematics in a programming language had me immediately.

I began learning on my own with the Natural Number Game, and then enrolled in the 2024 edition of Lean at CompuMates, a course at my university taught by Professor Jorge Carmona. The moment it ended, I asked Jorge to be my thesis supervisor. He agreed.

Our initial idea was a game in the spirit of the NNG, but about topology: The Topology Game. I have always been drawn to pedagogy, especially through games, and Lean's potential for learning is huge. In the end we did not go through with it, because my supervisor wanted me to finish the proof of Urysohn's lemma ↓, which ended up taking me months.

In the fall of 2024 I also started working at Basotek, where I kept working on formal logic and number theory. Eventually I introduced Lean at work too, and formalizing the papers we produce is now part of what I do there.

I defended my thesis in June 2025 and got the best grade possible. Right after, I enrolled in the MSc in Formal Methods.

Thanks to the people I met in the master's, I heard about ItaLean 2025, where I met the people who are now my MadLean ↓ co-organizers, and where the quotient manifolds ↓ project started. That project marked the beginning of my contributions to Mathlib.

In June 2026 I attended a workshop on formalizing Fermat's Last Theorem, where we tried an autoformalization tool that sparked my interest in AI and formalization, and in what the limits of that might be. Formalization has also opened the door to safe AI, which I would love to explore further.

These days I am juggling many things: contributing to Mathlib, working, and finishing my MSc. Next year I will write my master's thesis, hopefully on Lean. Over the summer I am also preparing a new edition of Lean at CompuMates for the coming semester, together with my supervisor.

As for what comes next: I want to devote my life to the formalization of mathematics, and I am actively looking for opportunities that take me closer to it, whether in Lean, formal methods, or AI for mathematics. If that sounds like something you are working on, write to me.

end About

section Projects

open Topology Manifold ArithmeticFunction

Proofs that compile

Projects I've worked on in Lean. Click a card to learn more.

Lean 4Differential geometry

I contributed to the Quotient Manifolds project during ItaLean 2025, and kept going afterward. That work has since grown into a series of contributions to Mathlib.

During the conference, my peers and I formalized a core fact: if a group acts freely and properly discontinuously on a charted space, the quotient space inherits a charted space structure.

That result became #35653, now merged and living in Mathlib (see the documentation):

Mathlib/Geometry/Manifold/Instances/Quotient.lean
/-- The induced charted space structure on the quotient of a charted space by a free, properly
discontinuous group action. -/
@[expose, to_additive]
instance instChartedSpaceQuotient : ChartedSpace H (orbitRel.Quotient G M) :=
  isQuotientCoveringMap_quotientMk_of_properlyDiscontinuousSMul.isCoveringMap
    |>.isLocalHomeomorph.chartedSpace Quotient.mk_surjective

I later gave a talk walking through the PR. The slides are online if you'd like a closer look.

The next step is extending this to full manifolds, which also requires the action to be smooth. This work is still open in #40727, a large PR I've been splitting into smaller pieces that are undergoing review:

  • #41832 adds Diffeomorph.smul: if a group acts on a manifold by diffeomorphisms, scalar multiplication by any element is itself a diffeomorphism of the manifold.
  • #41835 adds orbitRel.Quotient.quotient_smul_eq (⟦g • a⟧ = ⟦a⟧ in the quotient by MulAction.orbitRel, for any g) and Homeomorph.smul_symm (the inverse of Homeomorph.smul g is Homeomorph.smul g⁻¹).
  • #42436 adds StructureGroupoid.restr_mem_of_eqOn: if a partial homeomorphism agrees with a groupoid member on an open set, its restriction to that set is also in the groupoid.
  • #42502 adds symm_trans_trans_mem_maximalAtlas_of_contMDiffOn and symm_trans_trans_mem_contDiffGroupoid_of_contMDiffOn: conjugating a self-diffeomorphism by two charts from the maximal atlas produces a map that lies in the maximal atlas and satisfies the contDiffGroupoid n I compatibility condition, respectively.
  • more to come :)

Plenty more differential geometry contributions to Mathlib on the way!

Main Ideas

To construct the charted structure of , the main idea is to transfer the structure of via the projection . For each , we choose a representative and use the fact that is locally invertible near to pull a neighborhood of back into , where has a chart . The composition then gives a chart around , and collecting these charts for all points of yields an atlas, making the quotient a charted space.

For the manifold structure, you must show the composition of charts is smooth, that is, .

The key idea for this is to realize that, under certain conditions, this composition behaves as for the action by some chosen element .

Lean 4Topology

As part of my Bachelor's thesis, I completed an original formal proof of Urysohn's lemma. This was the first big project I ever completed in Lean.

Abstract

This project consists of an exploration of the Lean 4 system as a proof assistant through a case study: the formalisation of results in general topology. The main objective is to deepen the understanding of this system and to provide a critical perspective on its advantages and disadvantages when writing mathematics. A general overview of the foundational basis of the system, its syntax, and its concrete application to topology is provided. The project concludes with a description of the process of formalising the more complex result Urysohn's Lemma, as well as the insights gained throughout the work.

The full report can be seen online in Verso, and the code is available in this repository.

UrysohnsLemma/Separation/Urysohn.lean
lemma Urysohn {X : Type} {Y : Set ℝ}
    (T : TopologicalSpace X) [T' : TopologicalSpace ℝ] (hT' : T' = UsualTopology)
    {R : TopologicalSpace Y} {hY : Y = Set.Icc 0 1} {hR : R = TopoSubspace T' Y} :
    NormalSpace X ↔ ∀ C1 : Set X, ∀ C2 : Set X, C1 ≠ ∅ → C2 ≠ ∅ → IsClosed C1 → IsClosed C2 →
      Disjoint C1 C2 → ∃ f : X → Y, Continuous f ∧
        f '' C1 = ({⟨0, by simp [hY]⟩} : Set Y) ∧ f '' C2 = ({⟨1, by simp [hY]⟩} : Set Y) := by

The main difficulty of formalizing the proof of Urysohn's Lemma is best explained in Mathlib's documentation:

Most paper sources prove Urysohn's lemma using a family of open sets indexed by dyadic rational numbers on [0, 1]. There are many technical difficulties with formalizing this proof (e.g., one needs to formalize the "dyadic induction", then prove that the resulting family of open sets is monotone). So, we formalize a slightly different proof.

My supervisor suggested I formalize this without looking at Mathlib's version, following Willard's General Topology instead. Therefore, I ran into the problems mentioned above and had to overcome them in different ways. As a result, my proof is different than the one currently in Mathlib.

Proof Sketch

The main idea for the proof is building a nested family of open sets indexed by (rather than the dyadic rationals); starting from two closed sets and , normality repeatedly produces a new open set squeezed strictly between any two already placed: between and , then another between and , and so on. The resulting family satisfies whenever .

Extending that family to all of gives a function ; from there, collects every rational with , and finally is the separating function itself. Once exists, showing lands in , is continuous, and separates from is comparatively easy. Nearly all the real difficulty is in constructing and proving it monotone.

Building each is itself an induction, which meant inducting on the rationals. For this we fix a bijection and apply induction on the natural index instead. Proving monotonicity needed induction on two indices at once, which we get from the lexicographic order on : a well-founded relation Lean can induct on directly.

The real challenge wasn't the topology, but finding the right Lean objects to carry the argument: countability of the rationals, the lexicographic order, and non-standard recursive definitions.

Formalizing this proof was the hardest part of the whole project. The monotonicity property, which every source waves through as obvious, took me months to get right in Lean, and even after refactoring, my proof is still hundreds of lines longer than Mathlib's. Along the way I tackled problems like writing several different induction lemmas, and reworking my separating function to land in instead of so I could take its infimum.

This project was an amazing way to consolidate my topology knowledge, but above all it taught me a lot about how to actually think in Lean.

Lean 4CommunityTeaching
madlean-talk.jpg

After meeting at ItaLean, my peers and I realized there was no regular Lean meetup in Madrid, so we started one! MadLean was born, and I've been co-organizing it since.

We prepare talks, host visiting speakers, and work together on shared projects. I've given a few of these talks myself, including one walking through the quotient manifolds PR described above.

Teaching is where most of our energy goes. We've been teaching newcomers informally for a while, and with the growing interest we're now preparing a 10-hour introductory course at CompuMates (UCM) for the winter semester of 2026, supervised by my thesis supervisor.

-- Exercise 3: use `left` and `right`

example : P → (P ∨ Q) := by
  sorry

example : (P ∨ Q) → (Q ∨ P) := by
  sorry

I actually took this same course back in 2024, as part of my own path into Lean. Now I get to help renew it and give it new life.

I also keep the MadLean website updated with weekly posts!

Lean 4Number theoryAutoformalization

In July 2026 I participated in a workshop for the FLT project, Kevin Buzzard's effort to formalize Fermat's Last Theorem in Lean by 2029. For a week, around twenty mathematicians and Lean experts gathered in London to push the formalization forward. The workshop was centered around using AI assistants to autoformalize results known in the 1980s.

The Statement

Fermat's Last Theorem states that there are no positive integers with such that . Conjectured by Pierre de Fermat in 1637 (famously scribbled in a margin too narrow to contain his "proof"), it resisted every attack until Andrew Wiles finally proved it in 1994, over 350 years later.

Frontier models can now draft compiling Lean proofs of graduate-level mathematics, but what they produce is rarely clean enough to keep. So I took on the job of golfing and simplifying proofs written by an AI model on the topic of the Tate curve. The result was FLT #1091, a golf pass over TateCurveConstruction.lean making it about 200 lines shorter.

While cleaning that file, I also found results that didn't really belong in FLT, but in Mathlib. I extracted and generalized them into standalone PRs:

  • #41502 adds HasProd/HasSum lemmas for transferring infinite products and sums between and . The additive versions turn three private FLT lemmas, stated there for only, into one-line applications of general Mathlib API. I then went back to clean-up in FLT: FLT #1173.
  • #41498 computes for in closed form via Stirling numbers of the second kind, generalizing a special case proved in FLT.
Mathlib/Topology/Algebra/InfiniteSum/NatInt.lean
@[to_additive]
theorem hasProd_pnat_iff [TopologicalSpace G] [IsTopologicalGroup G] {f : ℕ → G} {a : G} :
    HasProd (fun x : ℕ+ ↦ f x) a ↔ HasProd f (a * f 0) := by
  simp [hasProd_pnat_iff_hasProd_succ, hasProd_nat_add_iff]

The workshop was my first hands-on experience with autoformalization: the newest models and tools had just come out, and we spent the week testing them on commutative algebra, representation theory and elliptic curves, learning how to prompt them, where they break, and how to review what they hand back.

I hope to keep contributing to FLT; there's plenty left to formalize before 2029!

end Projects

section Path

Still growing

I'm always juggling several things at once, which is why a normal timeline never quite fit; I see myself more as a plant, growing buds in several directions. Right now those buds are my MSc in Formal Methods, my contributions to Mathlib, research at Basotek, and a Lean course I'm preparing for next semester.

  1. Research at Basotek 2024 – now prime numbers, compression, formal logic and conjectures.
  2. Urysohn's Lemma 2025 an original formal proof, for my bachelor's thesis.
  3. BSc Mathematics 2019 – 2025
  4. MSc Formal Methods 2025 – now going deeper into logic and verification.
  5. ItaLean 2025
  6. Quotient Manifolds 2025 – now from a workshop project to Mathlib PRs.
  7. MadLean 2025 – now co-organizing Madrid's Lean meetup: talks and teaching.
  8. FLT Workshop 2026 golfing AI-written proofs and preparing them for Mathlib.
  9. Mathlib contributions 2026 – now differential geometry, infinite sums, and more to come.
  10. Now actively looking for growth opportunities.

end Path