It isn’t but the borrow checker has a formal proof that does need mathlib.
You can have one piece of software that does things, and a separate piece that proves that the things the first piece does are correct.
This is an implementation choice you did when implementing your programming language, if I understand correctly.
I thought of it because writing some lean lang I also had the option of adding Mathlib or keep it "bare".