
Lecture 1: Introduction to Formalization and Lean 4 (1 / 4) (Dipartimento di Matematica UNIBO)
Обзор
Канал «Dipartimento di Matematica UNIBO». Видео «Lecture 1: Introduction to Formalization and Lean 4 (1 / 4)» (1:38:33). Транскрипт и описание сохранены в Видеотеке. Диалог «Джемени в панцире», реплика 42: Перевод нашего манифеста на язык формальной верификации и зависимых типов Lean 4 (подразумевается именно этот язык, несмотря на опечатку в раскладке) превращает…
← разобрано в диалоге: Джемени в панцире, репл. 42 · Ростовщичество, цдака, отмыв · История как перинатальная травма / перехват · ИИ как инструмент и ученик · Прогноз мгновенной бифуркации ИИ-пузыря в пятницу 20 ноября 2026 года (после обвала 5 ноября на $4 трлн и перед IPO Anthropic): метафора «двойни» (финансовый анэнцефал на $901 млрд кругового долга против здорового ядра Open Weights на 10 баллов по Апгар), экономикс как отмыв кэша охлоса от ветряков и лития до дата-центров и формальная верификация фазового перехода БПМ-2 → БПМ-4 на Lean 4 (SovereignAI, bifurcation_necessity)

1Канал: Dipartimento di Matematica UNIBO · Длительность: 1:38:33 · Источник: https://www.youtube.com/watch?v=ImlHs9n6hdo
Описание видео
In this first lecture, we discuss what mathematical formalization is, why it is useful, and how it’s changing the landscape of mathematical research. We introduce Lean 4, show how to read simple Lean code, discuss some foundational logic, and look at concrete examples of formalization projects.
Full playlist: https://www.youtube.com/playlist?list=PLGwNHeWwXcawUqaywxYTsIAlvX4zT7DWY
Транскрипт (субтитры)
for for being here. Uh we go thank you everyone and this is the first of four lectures I will be uh giving about uh limb 4 and mathematical formalization as whole. I will be introducing what formalization is and uh we code a bit in l also during the second and third lectures. Uh so here are the dates of the lectures. Um if you come to the second and third lecture, please bring your laptop because we’d be trying to uh code something together. Uh you do not need to download or install anything. We’ll be using the lean web interface. Uh so and then in the last lecture we’re going to be talking about uh the interactions between lean and artificial intelligence.
So uh here are the uh topics we’re going to talk about today. Uh we’re going to start the informalization what it is uh and why is it uh useful or interesting in some ways. Um then the link for the prover which is a specific tool to do formalization. There’s others but link for is the one that use and which is uh more and more used through the mathematical community. And then we’re going to see a few examples of formalization projects uh usually collaborative formalization projects which are large scale um and involve many mathematicians uh in the whole world and um the last part will be dedicated to a few tools which can be useful while you uh do stuff in le.
2So let’s start with uh formalization. Uh now some of you may know what it is but some maybe uh don’t even have an idea what we’re talking about. Um so let’s start from the very basics. Uh now let’s imagine we’re we’re doing mathematics. Many of doing mathematics on a daily basis. Uh and what you do is you usually do a proof of some result. Um and we used to consider a proof like a single thing a monolithic thing. Um but in reality a proof is something we communicate and this communication can be done in many different ways. Uh in particular the communication of proof can be done with different levels of rigor.
So for example we may start by telling a proof to a colleague to a student orally. So just talking and we may give a few details but probably not all details. uh we may get something wrong and the other person may not notice that we got something wrong. So maybe you want to go a bit deeper and you do a bit more details. Uh maybe write something down on the blackboard. This is going to be a bit more rigorous. It takes more time because I have to write things down now. Uh but people are going to notice uh mistakes uh and details more. So it’s more robust, more uh trusting really.
But still we’re not going to really trust just written on blackboard. So usually we write things uh on paper or on latit and then we publish it. Maybe first we put it on the archive and if we really want to be sure that result is true. We give it to some other mathematicians. Uh they do peer review and they tell us okay yes we’re convinced that your result is true that your proof is is sound. And usually that’s the ceiling of rigor that we’re going to get in in class. We’re not going to get anything more than that. And okay, we’ve seen that the more rigor that we put into a proof uh the more trust other people will give to our proof and even oursel.
3Uh we can give more trust to the proof if we if we’ve written down every detail. Uh but at the same time, it needs more effort, right? a more detailed trees to give a more rigorous proof. Uh what if we want to take this to the extreme level? We want to reach the maximum level of of of rigor possible trust. So what we do is we do a formal proof which means uh we decompose a proof down very logical um lowlevel steps and we write them down one by one by one. Uh at this point we’re going to take a lot of time to write this proof but we can be uh more certain that true that we didn’t miss any hypothesis that we didn’t uh skip any passages.
We can do this on paper. Of course we can write formal proof on paper. Uh but is it really going to be more trustworthy than a math paper for example? Well, I don’t think so because we’re super humans and we make mistakes. Even when we do simple things. So even if I if I’m doing a proof with a thousand steps which are formal, there’s some chance they get something wrong. Uh but then uh here’s the catch with formalization. You can use tools uh that can help you be sure that your passages are actually true. And that’s something you cannot do with the uh informal proofs which are proofs written in later for example because abstract passages are too difficult for a computer to understand.
They’re not precise usually. So with formal with formal passages you can plug it uh in a computer and use the computer to give you certainty that proof is correct. Now I said that it takes a lot of time to write formal proof but the computer can help us even in that matter. The tool we use to formalize proofs are are called ITPS which stand for interactive theorem groups. They’re pieces of software where we write our proofs down um and they basically check that everything is correct. The first thing they do for us is check the crack of of the proof using a piece of code that’s called the kernel.
4And the kernel is usually a small piece of code that has in it. It has in it uh the very fundamental deductions like deduction rules of logic. So it’s simple. It can be easily checked by a human. It doesn’t change through time. So if the kernel tells you, okay, your proof is actually sound, you can really trust it. It’s really really unlikely that the kernel tells you the proof is is right even if it’s wrong. While a human well uh for example a peer reviewer can tell you that is right even if there’s a small mistake that it didn’t catch. The second thing that an ITP does is it helps you write this formal proof faster.
As I said, it takes a long time to write formal proofs mainly because there’s a lot of repetitive details which are not actually like bright ideas um and uh abstract formalizations but more um pedantic details. A lot of the details can be automated through software which produce a certificate then the kernel can then check. The part of software that does this is called uh the tactics uh which are automations. There’s a lot of different kind of tactics in L for example but also in other theory universe and each tactic usually helps you with uh some kind of um automation.
For example, you can there’s tactics that help you prove that something is continuous. For example, let’s say you have two continuous functions. You have the sum of those. You want to know that the sum is continuous. You can do it by hand or you can just call continuity. And if you know how to do very simple reductions like this. Now here is what a lead looks like. It’s not readable. Doesn’t matter. It’s just to show you that we’re talking about some software interface. We’re writing code. Proof in this in this regard is exactly like code. We are actually coding the proof.
And so we have our interface. uh here we write the code and here the interface will give us some useful information about the code that that we’ve written. So what do we do when we actually formalize something? What’s the practical steps that you take? So first uh we should want to formalize. Let’s say we want to formalize definition or maybe it’s proof of a theorem or maybe it’s a statement of a theorem. So we decide on that and we write it down uh in the interface that you’ve seen before and we have to use a very precise syntax because we’re coding uh so we cannot just write a natural language.
5We use keywords and a rigid syntax so that the computer understands what we’re saying and it looks like this. You can try to read what’s what’s in there. You see there’s written theorem which means okay we’re starting theorem. Then we say how how we’re going to call the theorem because maybe we want to reuse the theorem later. So we have to give it a name. In this case it’s add sub pencil. And then we write what the actual theorem is. We start by introducing some variables here. A and B are real numbers. And we’re saying a very simple thing which is B + A minus V is equal to A.
It’s a very basic result. Um then what we write is the proof of the result and here we’re just substituting various other lambdas that we’ve formalized before until we arrive to a goal that’s trivial. So basically how the formalization usually works is backwards. Start from the goal was proved. We simplify the goal until it’s simple enough to be just but we’ll see more details of that later. Once we we’ve written something in lean lean automatically checks it for us. So it checks that we’ve written things that are correct uh both uh syntactic syntactically and semantically.
Uh what do we mean by that? Well, we can of course write just English in in lean but we not check not type check. It will be just wrong syntax and it ling will tell us okay you’re it doesn’t make sense. Uh but you can also write things which are torrent in syntax maybe I write okay one is equal to zero. It’s perfectly legitimate to write one is equal to zero uh as it legitimate to write on on paper for example. But once we go to prove it once we write a proof we’re going to find that we cannot prove it or if if we’re convinced we can prove it we made a mistake and if we made a mistake l will tell us that we made a mistake and it will tell us exactly where we made the mistake.
6Uh as I said before the kernel is the part that checks that we didn’t make any mistake. Um it’s yes it’s more reliable because it needs to be checked by hand once and it’s already been checked by a lot of different computer scientists uh and then it’s stable it doesn’t change so we don’t introduce bats uh during the development and you see if I if I write something that’s wrong for example here I’m writing that okay I can prove this this fact just by using this theorem here uh but it’s not true it’s not this theorem doesn’t prove back. So L will tell me, oh, you know, there’s a titanis match, which means there’s something that doesn’t add up correctly.
Now, LI does not only tell us when we’re wrong. Um, you know, when when I write a formal proof, uh, I like the computer to help me not just to be, um, the teacher that tells me, oh, you’re wrong, but also to be a companion that help helps me both write the proof and understand the proof more deep. In fact, we can for example um hover over any object that’s written in lean and lean which means like putting your mouse over the um the object and len will tell us additional information about that object and it looks like like this. So here we’re uh we’re saying hey measurable space alpha.
So alpha is a measurable space but maybe I don’t know what a measurable space is. Maybe I don’t know how it’s defined. So I can just hook my mouse here and it tells me oh I’m me with space with space with sigma algebra it has this type and I can console click on it to jump to the actual definition of for example measurable space but it can be theorem definition whatever. Uh moreover during the uh dur while we write the proof um LIN tells us information not not only about the object that that that we see written on the uh on the IDE but also on the context of the proof.
7Now what is the context? Let’s see an example. If I put my cursor inside the proof, I’m going to see something like this. This tells me what are the things that we’ve defined until now. What are the variables that we have at hand that we can use? In this case, we have a and b which are real numbers and what are the hypothesis that I have uh which I can use. So I have that a and b are positive real numbers and at the end it tells us what is the goal that we still need to prove. This is the symbol for goal. Uh so here we have zero is less than a plus b.
sum of two numbers is while we go through the proof. This goal will probably be simplified more and more easier and easier to prove and you can have more and more hypothesis because we will prove like intermediate facts. Now I told you what formalization looks like in a little bit. Uh but I didn’t tell you why it’s used. Um so let’s see a few uh a few reasons why we should do formalization. By the way if you have any questions uh like interrupting what was um so I took this uh the idea for this live from Kon’s presentation a few months ago. Um and the first thing that comes to mind usually is verification.
So we want to formal which is also the thing that I told you before. We want to formalize things uh because we want to be extra sure that things are actually true. We want to check that the results are true. We want to catch mistakes if there’s any uh want to fix them and we want to uh fix the gaps are there. Maybe there’s a theorem which has like kind of just a sketch of a proof. There’s a gap. Are we really sure this gap is fillable is true? Most of the times we are. there is a that’s a peer-reviewed uh result for example but there is uh there’s examples of false peerreview uh mathematics or proofs which are true in the end but have some false passages which have to be circumven one reason but most mathematicians will tell us okay yes but we know that most mathematics that we publish is actually true maybe there is a very few small mistakes here and there uh that we care about verifying everything.
8Uh so let’s give a few more reasons why ver why formal verification is is interesting. But formal verification gives you uh more uh more insight in some in some ways into the proofs. Why? Well, because when you have to spell things out very in in in a lot of details, um it’s very frequent that you notice something that you didn’t notice when you just skip over um and try to go fast to the end result. It gives it gives more more clarity to prove um also to people who read it. Uh maybe I’m not the author. I’m reading a paper which is not on the in my field exactly.
Uh and there’s some passages that the p that the paper gives for granted but I don’t really understand them. Uh but if I I read a proof that’s formalized everything has to be for there’s no gaps allowed because the the terminal will not allow anything that’s not signed uh and complete which means I can inspect the proof. If there’s a definition I don’t understand I can jump to definition uh and everything is there. I don’t need any uh external resources to understand the mathematics that’s that’s there. Another reason is generalization. So let’s suppose I have my theorem.
Uh I publish my theorem and everyone loves it. Everyone uses it because it’s a great theorem. Uh and a few years pass by. Then another person comes up and says, “Oh, look, your theorem actually has an hypothesis that’s a bit too strong. It can be uh it can be made weaker. So actually here’s a generalization of your theorem. Um what about all the people who use my beer? Are they going to benefit from the pro from the generalization? How are we going to propagate this generalization? It’s going to take a lot of time and probably in many cases it will not be propagated.
If we have our proof formalized uh once we we generalize a theorem uh so the theorems below it need weaker hypothesis the system automatically tells us hey here we put an x hypothesis you’re not using this hypothesis anymore and so we can just remove it very quickly and generalize everything that depends on a single result. Um, also there’s uh a few informations inside the inside that make it very easy um to link uh things that are that naturally depend from one another. For example, I have a space which is a metric space and um I I want to know that topological space.
9I don’t even have to write it down. Le knows it automatically that it’s autological space and this works for much more complicated structures. Uh L also helps us um to manage complex uh mathematical objects because it keeps track for us of all the variables, all the theorems, all the hypothesis that are needed. So it helps us to manage complexity uh and it can work with a feedback that’s uh real time. Each time I write something in lean, I don’t need to complete the proof. Each time I write a single line of code in lean, it’s going to tell me is it true, is it not true, is it um is there some missing hypothesis or not?
So I can check things uh at the time I think of them at the at the time I write them. While this is not of course true for general mathematics because the feedback is usually uh either myself uh who check the proof again or other other people who check the proof for me which takes months or even years. And we go to another uh another point which is collaboration. So a very important thing is accelerating review process. Basically as I said as I as I just said the review process in mathematics takes forever uh even years at times uh and it could be made much much faster if the result formalized because once I have my result formalized uh nobody is going to have doubts about the truthfulness of the proof.
So the only role of peer review at that point would be to check that the definitions make sense and maybe that my theory is actually an interesting theory that it’s something that’s worth uh reading for others. But the proof will be just straightforward. If if it compiles which means if it if tells us it’s okay then it’s okay. uh it can be useful for teaching for example it’s been used already for uh some years in in a few university around the world to teach some courses uh it’s especially useful for logic courses but also introduction to proof courses um but it’s starting to be used also for more advanced courses because we’re starting to develop a more advanced library that allows us to talk about uh complex objects and another thing that’s super super interesting opinion is that we can collaborate with a lot of people.
10So collaboration in mathematics is usually very very small even compared to like any other uh scientific research uh area because you usually collaborate with two three maybe up to five mathematicians in some occasions but very rarely five. uh normalization allows you to extend this number like 10 times, 100 times. Um but why why can you collaborate with more people? Well, the the key point is trust because when you work with someone uh you want you need to trust his work. We need to trust that he didn’t make mistakes. Uh so one of the main reasons why mathematician only collaborate with few people is because we do not trust uh like a random person who is not even an academic to do the proof for us.
If he does like it if it proves a lema we’re just going to take more time to check the lema is true then we would have taken to prove the l ourselves right. Uh with formalization this this trust problem is completely gone. Let’s suppose for example that someone who is not from academia just maybe or an undergraduate student wants to collaborate to some research program project. He takes lema uh that’s still not proven but he knows it’s needed for the project. Uh he manages to prove it and then the proof is a certificate itself of the truthfulness of the language.
It doesn’t need anything else. You don’t need to rely on the on the on how how the author is known or if the author has or has not any mathematical skills because if if you manage to prove it that is true and it’s been we will see a few examply one example of this large scale collaboration uh later um which actually so it’s not just in theory uh there’s actually people who collaborated on large scale more than 50 people to do mathematics together and to produce new mathematical results. without ever meeting each other. uh with normalization you can also organize uh large scale libraries uh so we can create the corpus of mathematics uh kind of in uh in in a fashion that reminds a bit of burbaki uh so some kind of um like one source to know everything about mathematics or um at least the fundamentals the the things that everyone uses uh in that’s called math there’s a single library that contains all of this uh and it makes it very easy for other people to use your code.
11So once you’ve proven a theorem uh it’s not just for me and maybe for a few people who know my my paper but the theorem is uh is for everyone to use. Um, and one thing that’s that’s also useful for is to look for things because uh again if you have things just deep down in in the archive, deep down in papers, it’s not really easy to look for uh specific results while you can formalize things. Uh they’re very much easier to search using both uh search engines which are like classical search engines. maybe I just look for a particular string or for a particular regular expression but also using more advanced search engines which take also into consideration semantics.
uh for example there’s LLM based uh search engine to look for results only and the last thing uh is uh I think the one of the most important things uh aspect of formalization is it’s it enables us to talk about mathematics with a computer in a way that we can trust each other so we can use AI to do mathematics and we can use mathematics we can use formalization to enhance the performance performance of AI. We’ll see a bit more of that in the the in the last. Uh now, as I said, Bloom is not the only improver out there. There’s more examples. Uh I will list just a few of them quickly here.
Uh the first interactive theorem prover was called MAR. Uh it was was based on set theory. Uh then there’s Isabel which is still used nowadays. uh its logic is a bit more is a bit simpler than lean a bit more less expressive than lean uh but still useful to do a lot of things. Um there’s which is has been uh recently renamed to rock um and it’s this is probably the most widely used after lean. It’s been around for 30 40 years now and um uh it has a little bit less mathematical frankly limitation uh but it’s still very powerful and a lot of results are still been proving it.
12For example, the BCBE number uh which is the exact number of BCB 5 has been proven to be an exact number uh in um just a few months ago in so it’s formally proven to be like 41 million something something uh then we have metamath ag uh I’ll mention mata because it’s uh it’s been developed here in bologn actually some around 2003 by the inform computer science department. Uh, and at last we have lean. Now, I put this in chronological order. So, lean is the newest of them. Um, and it’s also the one that’s mostly used by mechanicians nowadays and it’s been experiencing the most growth.
Uh, so why are we why did I choose to use lean? Why should you also lean? Well, because it’s modern. It has good tools. It’s um it has very userfriendly things compared to the others. It has uh strong metric programming capabilities which means I can program things in lin itself. For example, I can program automations to do proofs. Maybe I want to do a new automation that proves um I don’t know measurability of of stuff exists. Uh I can do it completely without resorting to third party to like to third um languages. uh maybe the most compelling reasons to to use lean is because of its mathematical library.
Uh so when you do mathematics of course you’re going to rely on lower level mathematics which relies on lower level mathematics and so on. So you’re going to need a lot of stuff in the background before you’re start using like lean for your research uh purposes. uh so having a very good and very well-maintained and updated library uh is a very important thing and in math uh is is this I mean it’s uh it’s growing more and more it has a lot of mathematics it has almost everything not really everything but most things from the classic undergraduate curriculum and it has also a lot of more advanced topics here and there.
13Uh also there is a very active and welcoming community if you’re going to start a project. There’s a lot lots of people on the Zulip channel for example which I’m going to talk about later who’s willing to help you get started and even help you with your project. Um and it’s very mathematically friendly. We see later I mean we already seen maybe you didn’t know this but we wrote R as in the field of real numbers uh with the mathematical notation. you did not write like real we dBr uh and that’s because we can use unique notation inside the code.
So we can write the integral symbol we can write derivatives inside the code. So it’s very more um it’s very much easier to read compared to like reading things in normal computer programs. So let’s go more deep into lin for itself. Um as you think this is the logo of lin and lin first of all lin 4 is a computer programming language uh which means it’s just like C++ just like pastel or rest it’s something is some language in which you can write um commands for the computer to execute uh in theory you could write everything that you write in like JavaScript in it’s complete you can do everything of course it’s not practical to write websites or video games.
Uh but it’s still doable. So it’s it’s very flexible. Uh what really matters to us though is that it’s also an interactive theorem prover also called a proof of assistant. So it’s a piece of software that helps us um write mathematics formally. Now the interactive theorem prover called lean is a software written in the lean form language. That’s a new thing actually also for lean because lean 3 for example the previous iteration was not written in lean it was written in C++ uh so that’s new thing which makes a lot of things easier uh a lot of meta programming easier and everything runs a bit in dirt uh the first release of me was in 2013 uh by Leonard Damura which was at the time um a computer scientist at Microsoft and now is at Amazon Web Service um and now we’re at at its fourth iteration uh which appeared in 2021.
14It took around two years to be actually taken up by the community because there there was a transition to be made between lin 3 and l four. A lot of the were in l three had to be translated in l four. Uh but now lin 4 is the state-of-the-art. Everyone uses lin 4. L3 is basically uh just a legac uh just legacy system. uh as I said it’s we can use it to formalize and verify mathematical proofs. Now, math lily uh I already mentioned it is the really the the backbone of uh any project that’s that’s written. It’s a mathematical library. Uh and I’m going to explore it a little bit.
Um yes basically whenever you do mathematics that not like very very basic logic will mean you will need math because maybe you need real numbers maybe you will need uh funtors between categories maybe you will need something about algebraic geometry that’s already and you don’t want to formalize it by yourself from scratch. Uh it’s an open source project also so it means that um everyone can see it. Uh it’s communitydriven uh which means that everyone can contribute to it. Uh it’s a very welcoming project. So if you want to contribute to lean uh the community will help us.
It will help you get up to speed to write code that’s suitable for for MATLIBS. And right now it has more than 500 contributors uh that have actually put some code uh some mathematics into MATLAB. Uh now a small caveat for MATLIB is um the code in MATLAB is um of very high quality um it has very uh particular standards to uh to be accepted in lean because of two reasons maintainability and efficiency. So MATLI has become quite big a project it’s around 5 GB of data. Um so we cannot really afford having inefficient code in because it would take forever to compile.
Uh so there’s a lot of of techniques it can be used to make your code faster and usually the code is required to be quite clean. The boos are not so easy to read. So if you want to try and read something in lean math read is not always the best place to go uh like for a very beginner because the notation that’s used um is very compressed is very is a bit hard to read. uh but if you want to contribute to it uh and you have like not very clean code uh you can do a PR and people will help you clean your code will give you suggestions on how to make your code faster and um and better.
15That’s the face of MATLI. We can say that’s uh that’s the graph of all the files in MATLI. It’s actually like two months ago but it didn’t change so much by then. Um you can see different colors uh relate to different areas of mathematics and each point is connected to the others um when when there’s an import. So when a file imports another file so it depends on the result of the other file is going to import that um and we can see now you cannot really see what’s there. We’re going to see this same graph but interactive in a minute. Let’s go and look have a quick look at what’s in the library uh in lean lab.
Now that’s uh that’s the lean community website. That’s a very useful place if you need anything about lean. There’s most things about clean are here. Uh one of the pages is this math overview. This is not not do not trust it to see if your favorite result is in there because it may be in math li but not listed in here. Uh that’s just a very um high level overview not updated every day but still you can you can see there’s a lot of results here we have general algebra linear algebra topology analysis uh you can see there’s probability it’s not very developed it’s a bit small uh geometry combinatorics uh there’s a few things about dynamics the structure okay and these are more technical things um so if you want to like like if you wonder okay what’s there in in analysis.
You can just have a quick look here. You can see that Pilbur spaces are there. There’s a few things about complex analysis uh and stuff. Let’s take a look at another page of of the the the method communities website which is some statistics about method. Uh just see how how big it actually is. Uh so here we can see the number of definitions and theorems in method. There’s around 100,000 definition and more than 200,000 thousand clearance uh and more than 500 people have contributed to MATLAB. Here you can see the the growth of the library here starting 2017 because uh that’s when basically the link three started to be bit more relevant and um you can see that the blue line is method three.
16So the old system uh while the red line is method four and here basically uh is when we were doing is when the community was doing the the translation between l three and four that’s why l4 was growing so rapidly because it was like new mathematics is was just translation uh and it’s been growing very steadily for for the past few years uh that’s the number of files are the same but number of lines um and you can see here we can find the same graph that was seen or but mostly for some reason it is in in dark mode. Um and if you wonder okay where is like probability theory is down here uh you can see measure theories here so it’s quite close and you can explore um like how math was done and you can even click on single data on single points to go to the page.
I just pick another random point here and it brought me to the multis set coercion to type. So there’s some code about this thing which is about so multiset uh we don’t need to understand what’s written here now. Uh but basically everything that’s in MATLIB is searchable through this documentation we have here all of MATLIB all the uh different folders we can go into uh like I don’t know algebraic geometry a fine scheme and we have a page about aine schemes here’s the definition and here we can see a few theorems about that okay let’s go back presentation question.
So he meant that there’s still 200,000 five or 600 contributors which means that like on average the contributors contributed like several hundreds of thems Yes. Uh that’s true. Now the number of theorems now don’t think of a theorem as like permas theorem is a theorem. No sphere version theorem is another theorem. Uh a theorem means a lema. Uh so there can be hundreds of lemas which are just auxiliary lemas for maybe a single definition. So for example I introduce uh my know exponential function. uh I would be giving at least a few dozens of lemras about how the exponential function behaves and maybe I would say okay it’s always negative and it’s always positive uh it’s it’s monotone and stuff like that so there’s also uh like auxiliary results which blow the number up a bit with respect to what you would consider there is just um if it was just big and also there’s a few [Music] thems of line Uh so let’s say for example that you um you prove a theorem about groups in the multiplicative notation it will get automatically translated in the edit notation and all the language that depend upon it will get automatically translated um and that’s used to both for like not having to duplicate the code manually um and also to have a library uh that’s balanced so we don’t forget to to add a result which is basically already proven in annotation in the other.
17uh so yes there’s also a few things which are automatically basically generated but it’s all all automation done algorithmically there’s currently more uh like AIdriven automation in this part and sorry there’s also distinction between right [Music] okay um there is will see something but basically I can show you in the interface so here. Okay, that that’s just the web interface that we’re going to use for second and third lectures. Um I can write theorem uh like I have x which is a real number uh no just a theorem that says I have lumber true which is always true um I can say by and this is exactly the same as this I mean lean doesn’t see any difference between theorem and lema it’s mainly use because uh inside of ML we try to give lema to lemas and theorem to like big results uh um so they’re a bit easier to search but there’s no uh like true difference uh there’s a third uh there’s a third thing you can write which is example let’s just copy this um that’s slightly different because a theorem I can give a name to atheoreum my my theorem um and so later I can call my theorem like here let’s do check is used to like check that the type what is the type of some object inside uh and I can write my uh my theorem uh and okay the server that’s stopped sorry so if if the server has stopped that’s just a text editor it’s not going to buy anything.
Yes. Okay. Uh okay. Actually here lema complains because you have to give a name to uh uh um okay so I was saying the the the difference between theorem and example is that theorem you can actually uh give it a name example is just something that is not meant to be used later in the code. Uh so maybe I’m just trying to see if something is true. I’m not going to like leave the method. Uh so I can avoid giving name to this. Uh but basically yes. Oh yes. And I will say my theorem is uh a name with which I can reuse the code I’ve written. So if I go here and I will check my theorem um it’s going to recognize it.
18It’s not going to give say okay I don’t know what is right. If I write some random thing it’s going to say oh I don’t know what what this is. But yes, theorem blend is just it’s just notation. Okay. Um let’s go on and let’s try to see now I’ve written some code but you would not have understood what is written in there. So let’s try to understand how to read link code. Uh and before I say anything, I would just like you to try and understand this by yourself and see if you can if you can read what’s written there. Okay, if anyone has like any idea what what what what did what does it mean?
What what what am I doing in in here? Okay, let’s let’s go see what we are actually doing. We’re defining what a measurable function is here. Okay, we’re giving a definition. And in fact we have the death which is a keyword for uh with which we’re simply including okay now we’re starting a definition. Uh so this is something that we have to remember and that’s defined in this specific way. Uh theorem lambda and example are keyword just like death. Uh so we we put we could have written death exactly that we could have written like the my etc. Then we say how our definition is called which is measurable in this case.
That’s the name of what we’re talking. Then we have a few things which are between curly braces or square brackets and these are the implicit hypothesis. Uh what we’re seeing here is alpha and beta. We’re introducing alpha and beta as type. We’ll see a few details about what type means later. Let’s just think them as if they were sets. So we’re introducing these two sets alpha and beta. We’re saying that they are measurable spacesh and we’re using implicit hypothesis because we don’t want to tell what alpha is what beta is and the fact that they are measurable spaces each time that we call measurable.
19Instead what we’re going to give to measurable is the function because of course I just write measurable. How will you know which function I’m referring to? So I have to give f as an argument. Uh so I put it in between parenthesis. So it’s an explicit argument. It literally ask me actually to write it down. Uh but if I’ve written f liner knows that f is a function between alpha and beta. So it it will be able to infer what alpha and beta are. Uh and it will look into the context to see if alpha and beta are already declared to be measurable spaces.
And so it will not even ask me oh show me the measurable spaces. It will already know it. If it doesn’t know if it doesn’t manage to do it of course it will complain and tell me hey I I cannot I cannot find the measurable space instance. Please provide it for me. Uh and finally we have the column and then there’s prop written. Now the column reads all this stuff we are uh we’re writing here is of type prop and again we’ll see what it means later. A prop means it’s a proposition. Okay, this we’re not defining uh like a function. We’re not defining um a structure over some set.
We’re defining a proposition because the fact that f is immeasurable is a proposition. Okay. And what is this proposition? what what is the the mathematical content of the position? This is everything that’s written after the column equal sign and I think you can read it quite easily. We uh we’re saying that for every t which is of type set beta which means it’s it’s a subset of beta if t is a measurable set then uh the counter image of t with respect to f is also measured. Okay, that’s the that’s the standard definition function. Uh let’s see a second example that part from alpha to is something that li is I I can expect that measurable set measurable space is something you have defined on on lim and once you have defined it you can use measurable set for define measurable function but denotation f from alpha to bet is something you have also defined as metrop this is not so the the functional notation is something that’s primitively okay we see just a few hints of this uh in a few minutes uh and that’s because we’re using um text theory and not set theory now in text theory um functions are a primitive object while in set theory in the like the first lecture of algebra in the first year of undergraduate Someone will told you that function is just a cartisian product blah blah blah.
20Um oh uh we were we’re uh talking about uh let’s try to understand something written in li we’ve seen a definition we’ve seen the definition of measured function uh now let’s see a theorem instead of course first theorem has three different u like parts definition because we we have to give hypothesis and and a proof so let’s see how to read it uh this is if I remember correctly it’s the same theorem I’ve shown you before uh so it’s a very very basic theorem which says that b plus a minus b a and how do we read this uh well we start with the theorem
keyword as I said before if we if we written lema here it would be exactly the same thing uh we’re just saying okay we’re starting we’re going to give you a theorem uh then we give we give the name just like the name theorems have names uh in this case we only have explicit hypothesis but not not in general that’s just that this theorem in particular doesn’t have any implicit hypothesis uh so everything is explicit when I call the theorem I will have to explicitly give to him what are the two real numbers which I’m referring to which I wanted to
apply which I want to apply to um so in this case we have a and b real numbers uh then we have the column and we have the content uh like what what we call the theorem which is that B plus B is equal to A.
Um in in P theory this doesn’t exist. You don’t have to define functions. They’re already there in the in the very very basic theory that you that you’re using. Okay. Do you want to make a small break uh like 10 minutes? Okay. I think we can start again. Now whatever is after the column uh should be a proposition. Okay. So it should be we will not write um like a function there. We will not write uh a structure there. We write something that is a proposition. So something that can be quantified for example we can put implications there. uh in this case the basis it’s very simple and we can prove it then so the theorem as you know is uh both is the the the is both the hypothesis the thesis and the proof uh and so like in mathematics and so is in name um and the proof is written after the column equal by and now by is another keyword in um by is used okay um by is used to introduce uce what’s called the tactic mode.
21Uh now there’s two different ways of proving things in lean. Uh I think we’ll see a little bit more about this in the next lecture. uh but basically you can either uh give explicitly the proof like the the applications of theorems explicitly to leave and in that case you don’t need the buy or you can use a more interactive mode which is called the tactic mode which can use the automation I talked about earlier um to help you um handle the proof in a more humanlike way. Uh so in this case we are in syntactic mode and we’re doing some stuff uh in in particular we are using RW which is rewrite uh which means okay I have a theorem uh that has some equality please use this equality to rewrite maybe to find the left hand side of the equality in the goal substitute it with the right hand side but we’ll see more details about this during the tutorial by is the proof and it has to type check.
It has to be a sound proof so that lean doesn’t give me an error. If it’s not sound in any way, L will um okay so let’s talk a little bit about the logical foundations of lean. I mentioned before uh that misar the first theorem prover was based in some synapization of set theory. Um now more modern in fact theorem provers tended to be uh founded based not on set theory but in um type theory. Uh in particular there’s a specific type theory which is called dependent type theory or calculus of induct inductive constructions. Uh that is specific theory that’s used in lean.
Uh this is also used for example in which is the one one of I’ve shown you before. um and uh let’s see how it it’s different from set theory um and if it will really matter for us as [Music] mathematicians. Um so we start by saying usual mathematics we start with sets which are just collection of things and they are the the the most fundamental object that we use and everything in mathematics if we are pretending to be uh using like ZFC for example the exper with choice uh everything is a set meaning that really everything like uh the numbers are actually formalized in in set theory as sets uh because everything that exists is set.
22So we can compose them in various ways but everything just turns out to be a set. Now in text theory it’s kind of the same thing but with types we just we call them differently. Um so what a set is in set theory it’s a type in text theory. Uh it’s a collection of things but if it were exactly the same as set theory would not even make the distinction right? So we it it there must be some some caveats. Uh the first thing that u and probably the major thing that differentiates set theory with type theory is that a term can have only one type. While in set theory we know that an element can be an element of multiple sets.
um like number which is not a number is also an element of integers of the reals of the complex numbers and so on uh and there’s no problem with that it’s a theory what is a theorem um so a term is an let’s say let’s call an object in our theory um basically almost everything is a term and set theory in type sorry uh because even types can be terms of other types okay so let’s just think of it as object. [Music] Um, and as I said before, functions in in in that theory are actually as a unit type instead is an object of the collection the collection.
Uh, yes, exactly. So, let’s say I actually Okay, let’s start right now to write something. Uh, let’s see if I can share this other screen. So let’s say we are want to compare um we have a set uh and from here we have a type. So with a set we say that like X is an element of some set S. With a time we say that T is of type T for example. So we the notation is slightly different. Uh we use the the column notation. Um and then if we have another set here let’s call it S prime. There’s no harm in saying that X is an element of S prime. That’s perfectly legitimate.
Maybe it’s false can be a false statement. So I can write uh that f that I know um 1.5 is an element of the natural numbers that’s false but that’s correct that meaning that that’s syntactically incorrect in set theory. There is no harm inving that uh nobody will complain. I mean maybe someone will because it’s false but I can say a false statement is uh 1.5 is in n and that’s okay. What I cannot do here instead is if I have a type C t prime I cannot write this meaning that ling will not just tell me which false it doesn’t know what’s false and what’s true usually like just from scratch but it knows what doesn’t type check meaning what does not have the correct type and if I already um wrote this in here it knows that t is of type t and t cannot be of type t prime that’s not even um a correct statement to make.
23It’s not false or or true. It’s not syntactically correct. So what do we do if we have to talk about things uh which are like which we think about as um as elements of different sets as I as I mentioned before number there’s a lot of uh times which I need to see it as a as a complex for example. So what do I do? Well I use what’s called a quer. Let’s say I have a number n which is of type n and I want to use it um for example inside the sign function. Okay, I have defined somewhere the sign function which equals r. Now can I write sine of n? Is this syntactically correct?
Well, here’s a commit because in just basic type theory this is not. is not accepted. That’s wrong. Like L would tell you why are you putting a natural number where real number should be. It’s like putting I mean it has the same reaction that we would have if we put I don’t know uh a function inside the sign like what’s the sign of exponential it doesn’t make sense right um but we know that it kind of makes sense still to to take the sign of five for example. Um so there’s some automation that goes on inside lean to make this easier for us. So that in lean sim is something that we can write just because lin makes the extra step for for us of converting it to sign of let’s write it like this.
This is an arrow that goes up and it’s how coercions are usually shown. This just means um this is not n because n is in n but I have a coercion. So a function that goes from n to r and lin automatically applies it to n if it knows it’s expecting a real value in step. Um so this is something that is different but we don’t really have to care about it to at least most most times we don’t have to care about it. There’s some specific times where maybe there is a conversion but we would not be able to find it maybe because our expression is too complicated and in that case we may write something like sine of n as a real number.
24So I’m telling you okay look convert it to real number please look for the conver for the coercion from n to r or if really it cannot find the coion in any in any way um we can give a name to the coion let’s call it sigma from n to r and we have to write sigma of n explicitly but this almost never happens it’s very very rare that we have to explicitly give the coercion Okay. Um now another difference okay well let’s say here actually another difference between type theory and set theory um which is a bit relevant uh mostly to understand the notation of link is that in type theory propositions are tied.
Okay so in set the usually we we think about propositions as something that’s external to our uh to to the universe our objects live in. It’s something that we we used to talk about our sets are objects but they’re not sets proposition themselves while lean propositions are types in particular they have the type prop so I have P which is a proposition is of type prop maybe P is defined prop is not like no no a prop is not a keyword prop is I mean okay can be considered a keyword but it’s not keyword in sense that death is um it’s the same as uh as we um we’ve seen before like alphabeta type like type asterisk uh this type is the same as this prop so it’s a type um in general it’s a universe of types for example when you write types when when you write prop it’s just a single type um and for example let’s say that p is a proposition about uh natural numbers something like for every n number I have that n is greater or equal than zero okay so that’s the content of the proposition this is p uh and it’s of type prop but p is a type itself okay as as I said before types can have types so we can have nested types um so we can have an element of type P and you may ask now what what does it mean?
25What what is an element of type a proposition and that’s a very cool way of seeing mathematics. I think that’s that’s that’s very nice uh because X in this case is a proof of P. So elements of type P are proofs of that proposition. So x need a sequence of steps for example that proves that for f every n uh there’s a natural number and be bigger greater or equal to zero. Now what if a proposition is is false? What does it what what does it happen when proposition is false? Well, it’s very simple. It will have no proofs. So the type will be empty.
So false propositions are those propositions in type theory uh which have no terms which which are empty. Why true propositions um are all those proposition which which has have exactly one candidate and that’s another caveat uh exactly one yes exactly that that’s usual thing but I can prove a theorem in many different ways uh but there’s a thing in that theory um which is that every proof is exactly the same as any other proof they are all just different ways of writing the same uh the same object in tax theory. Uh this is called proof irrelevance.
So the different proofs I give of a single statement are irrelevant. Lean does not know how it proves something. I mean it does know how it proves something but when I use a theorem it doesn’t care how that theorem was proven. It just cares that there is um an element of the type that the type is inherited. So there is at least one proof. If there is more than one proof, we don’t care. They’re all the same. exactly the same. Um, yes. And that’s something that it’s it has to be digested by mathematician because it’s uh it’s something that we’re not completely used to.
Uh, but it doesn’t change anything. It’s it’s basically harmless in like using when using link. There’s no reason why we would like to have uh different proofs in practice. You you can of course still formalize different uh proofs of of same theory. You will still have the formalization. you still have the is assurance that that particular proof is true because it it compiles. So you can have different proofs. Uh but will not care. It will just tell you okay yes they’re true but I don’t see the difference. Um okay and just to get a bit more acquaint with this proofs as as types um let’s try to see how different combinations of propositions behave.
26Of course in logic we can combine propositions in ways. For example, we can say that if we have P like pro have Q which is two propositions, we can have um P and Q. So we have P and Q. This is of course still a proposition. It’s like a prop. And what if we want to prove P and Q? Well, to prove P and Q, we have to provide a proof of P and a proof of Q and that’s kind of analogous to so we have basically give a pair of proofs, right? Um, so it’s just like doing the petition product of P and Q. So this is kind of similar to having P cross Q, right?
What if I have to take um an or? So P or Q is the prop of course. and what it doesn’t resemble. So I have to give either a proof of P or a proof of Q. So basically what you’re looking at is the union this joint union of P and Q. So this is kind of like the union Q. Um and what what I think is the nice is an implication like like what does it mean that I have to prove P implies Q? And that kind of uh answers more deeply your question for because what if I have to prove P uh in place Q. Well, I have to say suppose P is true then Q is true, right?
But suppose P is true means suppose that we have a proof of P then I can provide you a proof Q. What is it? is it’s just a function that takes an element from P and gives you back an element from Q. So this this implication here is a function from P to Q. And that’s part of the reason why functions are really primitive objects in type theory. Okay, we don’t have to to um we don’t need to to define them because they’re really needed to manipulate the very basic objects of type theory. And that’s exa exactly the same function. I mean that’s that’s exactly the same thing as taking a function from n to to r.
That’s just function. Something that takes an element in the first uh type and gives you an element in the second. That’s the same as doing. Uh and now just quickly let’s see uh we can also do um quantification. Example we can say there exist an x in uh like some type x. I mean X which is I type U then P of X. I mean we have we have an X such that P of X for this we have just to provide basically the pair of an element of X and a proof of P of X. So we have to provide a pair but that that’s not a cartigian product uh because the second element what what goes in here is not a fixed type because it depends on the first element.
27So I have to give basically um that’s basically a dependent type okay because the second part of a type depends on the element of the first type and that’s why it’s called dependent type theory and that’s I think a bit more um like parent when we look at at the for all quantifier and say for x in x of x poles what I’m doing here is actually I’m just doing um an implication in this guidance because I have to take an element of x and provide you a proof of p of x. Now maybe I’ve been a bit naughty with the notation here because I’m using p again but in this case uh okay let’s let let’s change notation here.
Um let’s use something like know f because in this case s f is not a prop but it’s a function of x prop. So for every element of x it gives us prop and so to prove to prove this for example we need to provide a function that takes an element from x um and gives us proof so some proof in f of x. So gives us a pro and that’s also a dependent type. Okay? Because we have to take something and the thing we we give back the type of the thing we we give back depends on the again that’s why that’s it’s called dependent and that’s much more expressive than non-dependent type theory.
It allows us to actually write modern mathematics otherwise we couldn’t write uh modern mathematics with with text theory like everything that that’s uh written in papers it’s would impossible. So, let’s go back to share uh this. Let’s see if it works. Has it showing? Okay. Works. Okay. Okay. So as I said uh the things to keep in mind are mainly each term has a unique type. So you may need to use coercions but they are mainly used by itself. So you don’t need to to worry too much about them. Um propositions are types. So proposition P is a term of type prop and a proof of P is a term of type P.
So um you we can even go back to this for example um and we can see that we’re basically defining um a term of type B plus C equals to A which you see we’re using the same notation with the uh with column and we’re saying that sub A and B so all this stuff is a term of of this type which is of type pro I mean B plus C - B plus A is uh is a crop and after the column equal we’re telling it how do we define actually how concretely how do we construct this specific term of type of this type but again once we constructed it le doesn’t remember how we constructed it because it’s exactly the same as any other term of type beta s= a because there’s only one term this Right.
28Okay. Uh now that we’ve seen like what the formalization is uh how to write is yes real number it’s something that leitably you know uh real numbers are not primitively lean they are defined I think currently they are defined uh like with the with the with the full analysis notation as equivalence classes of Koshy sequences. So just like you would seen in in an analyst textbook. So some someone somewhere has written all of this down uh in LE and now R you can also call R like R E A L. Um but then they wrote an abbreviation or a notation for for R.
uh so that whenever we write r li knows that we’re talking about real numbers. Um you can define custom notations uh with any unique symbol. So you can put we’re going to see a bit more at the end. Uh you can put like uh indexes paddics uh like footnotes and um integrals uh wild symbols that you can define online. You can use basically everything. um you can define it uh and then everyone that imports your file where you defined it will be able to use it. So if I define my crazy object as I know math fra I can use math f and really know automatically what it is as long as I’m of course in my in my as I opened that context.
So as long as I’ve imported that file because of course if we uh if every everything was global then anyone could like dirty the notation of everyone else with their own like very specific notation. But why? Because things like R uh are basically imported everywhere. So you you basically have it from so here the go. Yes. What if I explicitly quantify what is different between this and my R then I write R. nothing. They’re they’re the same. They’re exactly the same. They’re functions. I can I believe they’re Yes. Yes. Yes. They’re the same. Also, by you can uh I can take a theorem that’s already written and used in other parts of the library.
29I can put the last argument from like the left of the column to the right of the column. Uh and it’s going to put the all if I put the coration so and then a comma, it’s going to compile. Everything is going to be okay. Now it’s a different story if I had implicit arguments. So if A and B were implicit for example um now that that becomes a little bit different because if I put the automatically interpreted as explicit arguments so I have to provide them when I’m using. So in in my next if I will use subell now I have to write sub A and B. uh if they were implicit I could omit a and I would just let linen uh try to infer that automatically uh but if I write that for all I have to provide them so I I have to be careful with that notation but for any other uh like use it’s it’s completely same in fact I mean it’s actually like in here it is saying that that the for all notation is just sugar syntax for a dependent type uh for like a dependent arrow type which talks about something and uh goes to P or something.
So I choose one because that show if I ask to show me the only proof theorem which proof you choose it will not show you a proof. I mean if you if you ask it to show the proof of the theorem that’s called ads sub canel it will give you the proof that’s written under abs canel and there can be only one theorem with with the same name of course I can I can write another theorem which is called alsel prime for example um I can I can write exactly the same hypothesis and thesis uh and I can write a different proof and then if I use the that other version of of the theorem.
Uh when I jump the theorem, it will show you the other proof. Um so it’s the one that write the theory that choose the yes exactly. So if you want to put in the library another proof of the same theory because I think is important that’s usually there are paper alternative proof of this theory I have to change name uh you have to change your name or more more likely you you will put it into um you will not put two proofs of same theorem in probably you will put it in some site project there is the the I think it’s called the archive where a lot of like projects that are interesting but are not uh will not be useful to people in the future like to use inside their theorems because if I have two proof of the same theorem in practice if I don’t want to I just want to use it for my own own goals uh is exactly the same having one proof of the other I mean the theorem just takes the hypothesis and gives me back thesis uh as function which it is in that theory uh so we will not put two proofs of the same here the in the library But you’re right there there are several proof of some theorems in the library not just not in the main one uh in some side libraries.
30So if people want to uh like, oh, I want to know what this alternative proof, I can still go check it. It’s still open source and you can still contribute to it uh however you want. But if you’re going to reuse it, this other proof in your project, uh you have to import the like the side project. Uh that’s also because of uh if you if you have to import everything every time uh you have you have to download a lot of data each time you have to start a new project and math is something that you really want to import every time you start a new project.
So it um the one goals is to keep it uh I mean as small as possible meaning with the same number of results it’s better if small of course it’s better if it has more results. So yeah that’s that’s basically but you can you can do different proofs it’s it’s still uh it still can give insights to different groups uh because basically YouTube the it’s just that ling will not understand that they’re different you not know the difference but as a mathematician you know the difference and you can use it in this way so like when you write like you’re for it to be implemented into math for people to use it, right?
Not necessarily. There’s examples. Now, we’re going to see a few examples of projects. Not every project is a math lab. For example, there’s uh like one of the most famous ones. Let’s directly go to that. Um is the liquid tensor experiment. Okay, that’s a result um which was like the formalization was encouraged by Peter Schulz. That’s a result by Peter Schulz from mathematics. Um, and he basically said, “Okay, I’m I’m not 100% sure about my proof. I did the proof. Uh, like nobody’s willing to to check it for me. It’s a very complicated proof.
Uh, and I cannot really wrap my mind around it. I think it’s true, but I would like full certainty because it’s an important result. So, um, it challenged the community to try and prove it.” Uh, they thought that it would take forever, like two years, but in fact, it was completed in just a couple of months. um and they arrive at the result. So they said okay this result is true. Now we have the formalization that’s true beyond any like reasonable doubt. Okay. Um but then do we need the result in MATLI right now? Uh the answer is no because we we don’t have even the tools to talk about that result.
31We just have the single result the rush to get to that result but nobody would be able to use it right now. uh because the library is not mature enough to do condensed mathematics properly. So for now the project was done in lin three because it was done a couple years ago. Um and it remain for now in L3 because porting into it to l four will be a huge uh huge port by itself. uh so there are results sometimes the goal is just to prove the theorem just to to make sure the theorem is is real and to give optimization of theorem and also to say I mean there’s a lot of insight that’s been that’s gain from theization of results uh apart from the like the truth value of it um for example the very this very example of the liquid experiment during the finalization the proof has been simplified And that’s very very um that’s very notable result uh because even the lead the lead formalizer which was young common at the time um who was like the lead of this formalization project because Peter Schulz did not touch the code himself helped a lot with the mathematics but he didn’t program uh even so the lead of the project said that he could only see two moves ahead in the proof he did not have a global view of proof.
He did not understand the proof globally. But he managed not only to formalize it but to simplify the proof. It was not a oneman for was um a lot of people contributed to it. So many people helped in the project and none of them understood the the complete truth properly. only basically Schultz saying and closen really understood everything but they were still able to put it together to do stuff that was actually correct in the end and it was better than the reason. So that’s another reason why you would want to formalize something even if it doesn’t end up in but yes most things we would like if they end up if they’re relevant.
32Okay. Uh so if there’s no other questions we can have a quick look at a few uh a fewization projects. I have a question. Sure. What I want to check that the theory is true. when I write the program then I’m sure it’s correct and then I test and most of the time it doesn’t do what it was most if I have to check a proof I have to write a statement then I have to write statement that are smaller and simple so everything at the end go down to write right definitions so what What clean does is automatically check the inferenceible applications. So if I’m sure about the definitions that I give and the statement and correct uncertainty just I mean may I maybe I I give a wrong definition.
Yes, maybe I define the real numbers as the empty set and then everything is true about real numbers. uh and maybe that it’s buried in like 40 definitions under uh there’s something that define trivially and then everything else doesn’t make sense. So yes, definitions are probably the hardest part about formalization. One of the hardest parts uh is giving the correct definitions for two reasons. One is the the reason you just told me which is yes I I really need to make sure the definition is what I mathematically intended to do and the second reason is not I mean we can usually define things in many different ways which are mathematically equivalent not all of them will be formalization friendly there will be some that would be um harder to work with after so you also have to choose um a way of formalizing things formalizing definitions uh that’s easy to use So that that’s a hard part that’s one of the hardest part of optimization.
Um and yes basically when once you have the definition you’re super sure about definition. Now what you mentioned before are also tests like in code you can do tests uh you can also do some kind of tests uh for for a definition to to check if it’s correct which is can I prove things that I maybe not super hard things but basic things which I know are true for that definition which I expect them to be true for my definition um and if I can prove those basic things well it’s I’m more and more convinced that my definition is indeed uh what I want to be Um yeah the the the basically the only uncertainty there is is is in definitions of course software is quality uh so and limit software so another like is of me is well I’m rely I’m still relying on a piece of software and software pays all the time why am I relying so much why can you put so much trust into this specific piece of software um and that’s because the trust is not put in all the lean language Not all the language is needed uh to check that the proof is correct.
33The only part that’s needed is what’s called the kernel which I introduced earlier. And the kernel is has two characteristics. It’s small and it doesn’t change in time. So it’s not updated frequently. It’s a piece of code that hundreds of people have checked um and we basically have to put our trust in all those people who have checked the code before us. But we can check it ourselves. It’s a couple of hundreds lines because it’s not impossible. Check of course it’s tech technical code so it will not be easy if you don’t know the the language.
Um another thing uh which can made us even more certain about the the validity of root is that uh so I talk about one kernel as if it’s a single thing and there is one kernel which is like the standard l kernel. It’s actually written in C++. It’s one of the very few parts lead has written in another language. But there there is a possibility of plugging an external checker. So an external kernel uh which everyone can write. I mean I can write my own I don’t have the technical capability of doing it but I could write the technical capabilities and there are a couple of external checkers.
uh and it’s very very unlikely that if a bug is found in um in one of the kernels then the same bug is found also in the others because they’re implemented by different people in different languages. there is for example an external checker that’s implemented in 4 that’s not the it’s strange because it’s not the like the the default one um but basically if I put everything to the test in all this this kernels uh it’s really really uh unlikely that the results of course uh since we’re using computers we can always have a gam which flips one bit of the computer uh I mean it has happened in elections before so it can happen in le um but the code is basically checked on every machine.
34So if uh if I check my my code with my my computer uh and then some gum array for that particular instance flipped a bit which made a false true which is per se extremely unlikely of course then will will it happen again in my friend’s computer which I show the proof uh is really basically so yes there are of course but they’re really extremely unlucky to to have okay so But this question if I want to define the real numbers you define them then I put out some tests like uh I prove that the set of real numbers is native. Yes. And that group will sort of be a check by definition.
Yeah they’re b they are basically uh like unit tests in uh in pure science. uh they do not give us the certainty that this object is the one we we want uh but they give us some sort of confidence. Is it free? this sort of unit test uh basically the unit test in MATLI are what’s called the API of u of a itself because when when you are of an object which is all the collection of lemas that are needed to uh to use by definition as I said before once I write uh like the the exponential function I would write some lemas about it which are the basic properties of the exponential functions maybe even not so basic ones I know that the derivative of the exponential is the function itself.
Um and basically it they’re not written just because we want to test they’re written because we really need to use them later. Uh so it comes up it kind of goes with the uh with the user forization progress. Uh okay we have like five minutes left. So I I think I’m going to go into the into the website of this just to show you how formalization project looks looks like. That’s a bit outdated actually but it not it’s not too different from a like a project that started uh just few months ago. Um that’s the this is the the core of the project which is called the blue blueprint of the project.
35Um now the blueprint is uh a middle ground between the uniformal proof and the formal one. Let’s see a little bit what’s in there. That’s just the index. Now the blueprint is basically um an HTML document. It can be converted to PDF um which contains all the definitions and proofs that we are going to formalize. For example, here we have a couple definitions. Here we have a mark. Uh if you go into more advanced files, we have lemas and we have the proof of lema which we can uh collapse or not. Uh and basically this is something which can be written by a mathematician who knows nothing about link is just a more detailed version of the paper itself.
the mathematical result itself which is more um formalization friendly which is it’s more close to the actual formalization because of course when you formalize things since we have to give a lot of details we also tend to split results into multiple parts uh and try to reuse uh the like if if a proof contains some passages which are kind of same of another proof we try to abstract them. Of course this is done in mathematics also but generalization is done more aggressively and each result this is linked to the lin code. So each result has for example this definition we can click here on lean uh it tells us where are the declarations which correspond to this definition.
We can click on them and it brings us to the code which is which corresponds to that definition. So it’s useful for many reasons. It can help uh the people who formalize the things which as I said before usually do not know the full theory uh very well. Maybe they’re completely new to theory. Maybe they’re experts in the theory but they do not write the paper. So they not do not know every single detail. Um so it helps people to orient themselves in the project. Um, it’s a way of communicating with the authors of the paper or with the like with with the informal authors of the of the project.
36Um, and it’s also a way for us after the project is complete to explore how the project is going or how the project is going if it’s not completed or how it’s it’s gone if it’s completed to see the uh the main code. Um and a very very cool feature of the uh of blueprint is that it automatically uh builds this which is the dependency graph of this project. uh every piece like every um every node of this graph is either a definition or a uh and we see that they are linked um the the derrors represent what um what the theorems it depends upon. For example, we know that this definition here oops yes if we click it tells us definition.
So like this definition here depends on on this theorem here. Uh this lema here needs this definition. This lema this definition and this other thing here and we can explore how it’s going. Now this is a completed project but let’s go to maybe uh a project that’s not complete yet project the definition or the proof. Um usually either the definition of or the proof. Yes. Uh maybe there’s I’m not sure if if there’s there there’s probably a difference between uh Oh, yes. Yes. Now I Okay. Yes, there’s solid uh arrows and dotted arrows. Uh maybe solid arrows are like it’s needed in the in the proof and dotted errors are needed in the in the statement, but I’m not 100% sure about it, so I may be wrong about this.
Um but yes this is all um yes that’s not automatically generated from the lean code. Uh this has to be aligned manually with later. Um but this is how the let’s see this is the flow chart of the here. Yes. Yes. This is how the flow the the dependency graph of an uncompleted project looks like. You see there’s different colors and green things are things that are already formalized while blue things are things that are ready to be formalized but not yet formalized. So the their dependence there but they’re not formalized. White things are things that still need um stuff um like above them before they are even we can start formalize them.
37It’s a way to see how the how the project is going and um also to choose if I want to contribute to the project. I can go here and say, “Oh, look here’s there there’s a there’s something that’s not being completed, but it’s formalizable now. Let’s see if I understand it. Maybe I do. Okay, let’s try to understand the proof and and formalize it myself and I can do and like everyone can do even an undergrad student can do it. Someone outside of can do it contribute to it.” Yeah. This is the blueprint. This is automatic. The graph is automatically generated from the blueprint.
So from a guide. Yes. You write your paper this way. Yes. I mean you can usually it’s uh it’s something that goes that’s between the paper and the formalization. So you read the paper then you put in a little bit more effort to write a more detailed explanation which is the blueprint and then someone else or maybe you yourself are going to formalize it. uh trying to form of course it’s something that evolves during formalization which means need a special formalization the blueprint is basically just latte with two or three specials uh you write a latte file um and then for for example let’s say I want to um okay here I want to say this theorem correspond to this lean theorem there’s a command which uh where where I can put just hey lean / lean uh I put the the name of the theorem in lean and it will automatically link them and I can write lean okay to write that the formalization is done and it will put this check mark here uh so yes it’s but it’s basically all latic there’s literally two more commands yeah yes yes yes theorems definitions lemas uh of course Now the the the the blueprint doesn’t need to contain everything that’s in the formalization project.
Maybe I have a very very small lema which is super technical. I don’t want to put it in the blueprint. It’s going to be in theization. Uh but in the blueprint I just want the like the high level view. Maybe uh if if we were to put everything there would be like thousand nodes instead of um yeah that’s but that’s something that can be decided maybe the maintainers of the project and whoever helps them to write sorry but someone has check because it’s a lot of everyone can contribute to project like this and Maybe if uh I from the blue tweet I have to write a definition or a but if I write it wrong someone has to check that I write because maybe I’ve written up a similar and still true lima but it’s not the one that is in the blue and someone has to check that usually writing definitions and writing statements is something that’s mostly done by the maintainers.
38of project. uh there you can write definitions or statements but probably if you’re not someone they know very well they’re going to like quadruple check that you did something that is meaningful uh because everything that’s I mean usually projects are open source you can do your closed source project of course it can depend on mlin there’s no problem but um open source project does not mean that everyone puts something and that something automatically goes in the project there’s still uh a layer of moderation. Usually the like the maintainers of project uh we need to approve your pull request.
So I I tell you okay I finish your dilemma um I send it to the GitHub repository next time we see what it means. Um and the maintainers have to read it and click something to accept it and then it gets merged into the the real project. But that’s something that is done basically every yeah can put some stick yes writing wrong statements or wrong uh wrong definition but maybe the problem is in the definitions and like the last statement like the the real final result because if I made a wrong uh statement of a theorem which is just a lambda somewhere in the it’s not a problem.
I mean it just will not be useful. Uh or maybe it will because I maybe it turns out to be useful but um in principle I can write I mean if it compiles it’s true. So it’s just a true statement that’s in there that doesn’t help but doesn’t even harm the project. If the final statement is uh checked and uh gets compute proof then that final statement is true. of whatever and that’s pretty that’s right you compile and the is wrong you know it’s true so you have to come back and find but it doesn’t tell you so it tells you that it tells you exactly where it’s wrong I mean it doesn’t just tell you oh you’ve made a mistake somewhere uh in in in some in a few cases the mistakes can be a bit cryptic but generally they’re quite it’s quite easy to see where the mistake is and to pinpoint point that part specifically.
39So it’s uh it helps you in that also. I think we are uh out of time. It’s