
Mathematics in type theory - gbrown_
https://xenaproject.wordpress.com/2020/06/20/mathematics-in-type-theory/
======
xelxebar
For anyone interested in formal verification, there's this super slick project
Metamath Zero [0] by Mario Carneiro that is working to implement a verifier
that can verify itself, compiled binary and all.

As discussed on the project page, Lean is aimed at being _ergonomic_ but at
the price of a large (and somewhat buggy) codebase. On the opposite end of the
spectrum is Metamath [1] which aims at being the minimum needed for formal
verification, but at the cost of extremely pedantic (albeit interesting!)
proofs.

Metamath Zero, attempts to find a happier balance by designing a language
which is both ergonomic for the proof-writer as well as minimal enough to
allow self-verification.

At the moment, the project is still pretty alpha but Mario is both extremely
talented and actively developing. That said, if you are someone like me and
just want to dive into the math, definitely check out Metamath [1]. It's
library of proofs for standard ZFC foundations, set.mm [2], is seriously
impressive. I mean, you can find a proof of the fundamental theorem of
calculus and trace it all the way back to axioms if you so please (see
theorems ftc1 [3] and ftc2 [4])!

For someone with a background in math, the set.mm [2] database is an absolute
blast to rogue around in. It takes some getting used to, but I am starting to
prefer set.mm over Wikipedia when applicable.

Anyway, I love this stuff!

[0]:[https://3g2upl4pq6kufc4m.onion/html?q=metamath%20zero](https://3g2upl4pq6kufc4m.onion/html?q=metamath%20zero)

[1]:[http://us.metamath.org/mm.html](http://us.metamath.org/mm.html)

[2]:[https://github.com/metamath/set.mm](https://github.com/metamath/set.mm)

[3]:[http://us.metamath.org/mpeuni/ftc1.html](http://us.metamath.org/mpeuni/ftc1.html)

[4]:[http://us.metamath.org/mpeuni/ftc2.html](http://us.metamath.org/mpeuni/ftc2.html)

------
xelxebar
Not the point of the article at all, but in my experience when an author says
"canonical map" it can typically be made precise as a unique natural
transformation between whatever functors capture the objects of discussion. I
think this is part of what MacLane meant by Category Theory being invented to
talk about natural transformations.

------
nextos
Avigad, one of the Lean authors has several resources cited elsewhere in Xena
Project. These are really useful to learn the necessary background [1,2].

IMHO, logic and type theory are the algebra and calculus of computer science.
CS degrees should be designed around some core courses on these, in the same
way Math degrees tend to build up on linear algebra and real analysis
coursework.

[1]
[http://avigad.github.io/logic_and_proof/](http://avigad.github.io/logic_and_proof/)

[2]
[https://avigad.github.io/formal_methods_in_education/](https://avigad.github.io/formal_methods_in_education/)

------
somewhereoutth
Should a language be able to form predicates total over all possible
expressions in the language (including these predicate expressions) in a non
trivial way, could these be then identified as 'types' in the sense that each
can partition the set of all expressions in the language into 'of the type'
and 'not of the type'? Is this still type theory, or something else?

~~~
Kutta
Usually it's not possible to form such a predicate. If we have impredicative
base universe, then it's possible to form a predicate over all types in the
base universe (which may or may not be _all_ types in the language), including
the predicate itself. However, this feature is rarely used in type theory,
because it is incompatible with classical logic.

In programming, this is more commonly available, because we don't necessarily
care about propositions, let alone classical logical proofs. The polymorphic
identity function type `forall a. a -> a` in System F quantifies over all
types including itself.

------
asplake
Is it just me, or is "proof" used in two ways also – the logic and the result?
To use the given example, do I need to understand the logic of the Bolzano-
Weierstrass proof in order to use it?

~~~
Smaug123
It _is_ both, in the same way as a function is both its implementation and its
"extension" (its effect on all inputs). You don't need to know how `sort` is
implemented, if you know that it sorts; similarly, you don't need to know how
Bolzano-Weierstrass is proved if you want to use it.

~~~
galimaufry
> It is both, in the same way as a function is both its implementation and its
> "extension" (its effect on all inputs).

Note that, according to definition of 'function' most common in math, this is
false. A function need not even be implementable.

Aside: As someone trained in math I've always found explanations of type
theory "fractally confusing" because of stuff like this: type theorists' words
mean something different from my words, and in the explanation of what they
_do_ mean, they use words that also mean something different.

~~~
lmm
A function is rather like a group: it's more important as an idea than as a
rigorous definition. Working mathematicians may be vaguely aware that a
function "is" a set of ordered pairs (just as they may be vaguely aware that a
real number "is" a Dedekind cut), but they're unlikely to think about a
function in those terms when they're actually working with it (unless they're
working specifically on foundational issues). Indeed the set-theoretic model
of a function accommodates impossible functions - but that's one of the main
problems that type theory exists to solve. The type-theoretic model of a
function does not correspond directly to the ZFC model of a function, but the
hope of type theory is that it should correspond _more_ closely to the day-to-
day working concept of a function (whether you're a mathematician or a
programmer).

------
h8hawk
The title "Mathematics in type theory" is like mathematics in real analysis or
set theory.

~~~
guerrilla
It is like mathematics in set theory, as set theory can be used for a
foundation of mathematics; however, it is not like real analysis, because real
analysis cannot be used as a foundation for mathematics (without torture.)

~~~
h8hawk
I think you missed my point. The type theory is mathematics. So saying that
math in type theory is nonsense.

~~~
guerrilla
I'm sorry but you misunderstand the situation. Set theory, type theory and
category theory can be used for metamathematics [1] whereas real analysis and
number theory cannot. They are foundational theories whereas real analysis and
number theory are not. The reason for the difference has to do with the
expressiveness of the formal languages and how they themselves can be
expressed without a prior language other than formal logic itself.

[1].
[https://en.wikipedia.org/wiki/Metamathematics](https://en.wikipedia.org/wiki/Metamathematics)

[2].
[https://en.wikipedia.org/wiki/Foundations_of_mathematics](https://en.wikipedia.org/wiki/Foundations_of_mathematics)

~~~
h8hawk
I know they are foundations of mathematics. They are elements of mathematical
logic. No disagreement on this.

But how they are not mathematics? They are part of mathematical logic and
mathematical logic or logic in general is branch of mathematics. Do you want
to say they are somehow separated from math?

~~~
guerrilla
They are mathematics: mathematics about mathematics is what metamathematics
means.

