This is not an officially supported Google product
Metamath.js is an independent metamath verifier written in JS so that it can run in browsers.
It comes with a parser, a verifier and a renderer.
https://google.github.io/metamath.js
It also comes with a few experimental extensions to the language around modularization.
The Parser API takes as input a metamath source and calls a handler as it produces the AST:
> const {parse} = require("./src/descent.js");
> parse("$c a $. $v b $.", {feed(statement) { console.log(statement); }})
[ '$c', [ 'a' ] ]
[ '$v', [ 'b' ] ]
The Verifier API takes as input a metamath source and verifies the statements. It uses the Parser internally:
> const {Verifier} = require("./src/descent.js");
> new Verifier().verify("$c a $. $v b $.");
0
The Compression API manages decompressing (and compressing) proofs using the metamath compressed proof format:
> const {Decompressor} = require("./src/metamath.js")
> const compressed = "AAABZBZFAACAFABBGFBAFCAFADEE";
> const integers = new Decompressor().decode(compressed)
[
1, 1, 1, 2, -1, 2, -1, 6,
1, 1, 3, 1, 6, 1, 2, 2,
7, 6, 2, 1, 6, 3, 1, 6,
1, 4, 5, 5
]
> const local = ["wph"];
> const external = "wi ax-1 ax-2 ax-mp".split(" ");
> const steps = new Decompressor().decompress(local, external, compressed)
> steps
[
'wph', 'wph', 'wph', 'wi',
-1, 'wi', -1, 0,
'wph', 'wph', 'ax-1', 'wph',
0, 'wph', 'wi', 'wi',
1, 0, 'wi', 'wph',
0, 'ax-1', 'wph', 0,
'wph', 'ax-2', 'ax-mp', 'ax-mp'
]
> new Compressor(local, steps).compress();
'AAABZBZFAACAFABBGFBAFCAFADEE'
git clone https://github.com/google/metamath.js
git cd metamath.js
npm install
npm test