ArticleslgStudy

mathematics

Metamath

Metamath is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Metamath rather than just read about it. In short: Metamath is a formal language and an associated computer program (a proof assistant) for archiving and verifying mathematical proofs. Several databases of proved theorems have been developed using Metamath covering standard results in logic, set theory, number theory, algebra, topology and analysis, among others.

Metamath — main illustration
Metamath — illustration

Key takeaways

  • Metamath belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Metamath to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Metamath from memory before moving on to harder problems.

Reference excerpt

Metamath is a formal language and an associated computer program (a proof assistant) for archiving and verifying mathematical proofs. Several databases of proved theorems have been developed using Metamath covering standard results in logic, set theory, number theory, algebra, topology and analysis, among others. By 2023, Metamath had been used to prove 74 of the 100 theorems of the "Formalizing 100 Theorems" challenge. At least 24 proof verifiers use the Metamath format. The Metamath website provides a database of formalized theorems which can be browsed interactively.

Metamath language The Metamath language is a metalanguage for formal systems. The Metamath language has no specific logic embedded in it. Instead, it can be regarded as a way to prove that inference rules (asserted as axioms or proven later) can be applied. The largest database of proved theorems follows conventional first-order logic and ZFC set theory. The Metamath language design (employed to state the definitions, axioms, inference rules and theorems) is focused on simplicity. Proofs are checked using an algorithm based on variable substitution. The algorithm also has optional provisos for what variables must remain distinct after a substitution is made.

Language basics Comments are enclosed in $( ... $) . The set of symbols that can be used for constructing formulas is declared using $c (constant symbols) and $v (variable symbols) statements. The end of a statement is denoted by $. . For example:

$( Declare the nine constant symbols we will use $) $c 0 + = -> ( ) term wff |- $. $( Declare the five metavariables we will use $) $v t r s P Q $.

The grammar for formulas is specified using a combination of $f (floating (variable-type) hypotheses) and $a (axiomatic assertion) statements. Each such statement is preceded with a name so that it can be referred to in proofs. For example:

$( Specify properties of the metavariables $) tt $f term t $. tr $f term r $. ts $f term s $. wp $f wff P $. wq $f wff Q $. $( Define "term": zero and sums $) tze $a term 0 $. tpl $a term ( t + r ) $. $( Define "wff": equations and implications $) weq $a wff t = r $. wim $a wff ( P -> Q ) $.

Axioms and rules of inference are specified with $a statements along with ${ and $} for block scoping and optional $e (essential hypotheses) statements; for example:

$( Axiom a1: substituting in equations $) a1 $a |- ( t = r -> ( t = s -> r = s ) ) $. $( Axiom a2: Zero is neutral $) a2 $a |- ( t + 0 ) = t $. $( Define the modus ponens inference rule $) ${ min $e |- P $. maj $e |- ( P -> Q ) $. mp $a |- Q $. $}

A single construct, $a statements, is used to capture syntactic rules, axiom schemas, and rules of inference. This is intended to provide a level of flexibility similar to higher order logical frameworks without a dependency on a complex type system.

Proofs Theorems (and derived rules of inference) along with their proofs are stated with $p statements. The proofs are introduced with $= and are given as a list of names of axioms, rules and theorems to be applied. For example:

$( Theorem th1: reflexivity of equality $) th1 $p |- t = t $= $( Here is its proof: $) tt tze tpl tt weq tt tt weq tt a2 tt tze tpl tt weq tt tze tpl tt weq tt tt weq wim tt a2 tt tze tpl tt tt a1 mp mp $.

This abbreviates the following detailed proof:

The "essential" form of the proof elides syntactic details, leaving a more conventional presentation:

Substitution

All Metamath proof steps use a single substitution rule, which is just the simple replacement of a variable with an expression and not the proper substitution described in works on predicate calculus. Proper substitution, in Metamath databases that support it, is a derived construct instead of one built into the Metamath language itself. The substitution rule makes no assumption about the logic system in use and only requires that the substitutions of variables are correctly done. Here is a detailed example of how this algorithm works. Steps 1 and 2 of the theorem 2p2e4 in the Metamath Proof Explorer (set.mm) are depicted left. Let's explain how Metamath uses its substitution algorithm to check that step 2 is the logical consequence of step 1 when you use the theorem opreq2i. Step 2 states that ( 2 + 2 ) = ( 2 + ( 1 + 1 ) ). It is the conclusion of the theorem opreq2i. The theorem opreq2i states that if A = B, then (C F A) = (C F B). This theorem would never appear under this cryptic form in a textbook but its literate formulation is banal: when two quantities are equal, one can replace one by the other in an operation. To check the proof Metamath attempts to unify (C F A) = (C F B) with ( 2 + 2 ) = ( 2 + ( 1 + 1 ) ). There is only one way to do so: unifying C with 2, F with +, A with 2 and B with ( 1 + 1 ). So now Metamath uses the premise of opreq2i. This premise states that A = B. As a consequence of its previous computation, Metamath knows that A should be substituted by 2 and B by ( 1 + 1 ). The premise A = B becomes 2=( 1 + 1 ) and thus step 1 is therefore generated. In its turn step 1 is unified with df-2. df-2 is the definition of the number 2 and states that 2 = ( 1 + 1 ). Here the unification is simply a matter of constants and is straightforward (no problem of variables to substitute). So the verification is finished and these two steps of the proof of 2p2e4 are correct. When Metamath unifies ( 2 + 2 ) with B it has to check that the syntactical rules are respected. In fact B has the type class thus Metamath has to check that ( 2 + 2 ) is also typed class.

Metamath proof checker The Metamath program is the original program created to manipulate databases written using the Metamath language. It has a text (command line) interface and is written in C. It can read a Metamath database into memory, verify the proofs of a database, modify the database (in particular by adding proofs), and write them back out to storage. It has a prove command that enables users to enter a proof, along with mechanisms to search for existing proofs. The Metamath program can convert statements to HTML or TeX notation; for example, it can output the modus ponens axiom from set.mm as:

⊢φ&⊢(φ→ψ)⇒⊢ψ Many other programs can process Metamath databases, in particular, there are at least 19 proof verifiers for databases that use the Metamath format.

… excerpt ends here. Continue reading the full article.

Illustrations

Metamath: A step-by-step proof
A step-by-step proof
Metamath illustration

Worked examples

Example 1 — a first encounter with Metamath

Start with the simplest possible case. Write down what Metamath claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Metamath before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Metamath ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Metamath

In research
Metamath appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Metamath in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Metamath is common in secondary-school and first-year university syllabi. It links to neighbouring topics Free mathematics software, Free theorem provers, Large-scale mathematical formalization projects, so understanding it makes those chapters shorter.
In everyday life
Look for Metamath outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Metamath” →

How to study Metamath in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Metamath means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Metamath out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Metamath in simple terms?

Metamath is a formal language and an associated computer program (a proof assistant) for archiving and verifying mathematical proofs. Several databases of proved theorems have been developed using Metamath covering standard results in logic, set theory, number theory, algebra, topology and analysis…

Why does Metamath matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Metamath?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Metamath.

Tags

  • Free mathematics software
  • Free theorem provers
  • Large-scale mathematical formalization projects
  • Proof assistants

Keep exploring