Metamath was originally designed with a great deal of freedom in its syntax to allow math expressions that resemble what humans are used to. It also was intended to allow for ambiguous grammars such as that in
miu.mm (which in restrospect I half wish I'd never heard of :). My assumption, perhaps misguided, was that $a's, even for syntax, are "axioms" to be vetted by humans, just like we need a human to vet the axioms of logic and ZFC, and should not be tinkered with by novices who don't understand the consequences. Keep in mind that I originally designed the language primarily for my own modest use. I never imagined that it would grow into the incredible project it has become.
Careless or intentional ambiguities in a Metamath database grammar can allow us to prove contradictions without violating the spec. The language does exactly what it is intended to do, which is to prove consequences of $a statements, and as the saying goes, "garbage in, garbage out." While grammar soundness can be (and now is, thanks to Mario and David) automatically checked at a higher level (outside of spec validation and proof verification) by tools such as mmj2, it still makes the language conceptually much more complex than it could be.
The Metamath Solitaire applet, written several years after metamath.exe, took a different approach that I was pleased with. I made the grammar much more restrictive, requiring formulas to be expressed in Polish prefix notation, with a separate mechanism for displaying human-readable formulas. The syntax definitions in the applet store both Polish prefix for working internally and a display notation for the screen. (Polish prefix is much easier to work with in the code.) The user is not aware of the Polish prefix underneath. After writing the applet, I considered modifying the Metamath language to become a variant of the Metamath Solitaire "language" (which is hard-coded into the program since at the time applets could not read files), but I didn't pursue it.
Polish prefix notation is essentially immune to ambiguous grammar abuse. It is also trivial to enforce in the Metamath language: simply require that all $a statements for syntax consist of two constants (a typecode and a new constant for the operator) followed by zero or more variables. This restriction does not allow us to express a language with an ambiguous grammar such as that in
miu.mm, but I don't see that as a major loss.
For those who like the simplicity and perceived additional rigor and robustness of Polish prefix, it would be relatively straightforward to automate the creation of a Polish prefix version of say
set.mm, and also do it in a way that it can be converted back to the original. The Polish prefix version would continue to be a valid Metamath language file that can be verified with existing verifiers. If desired, a verifier could be enhanced with a "Polish" option to ensure the syntax $a restriction I mentioned.
In order not to lose the "human" notation for converting back to the original
set.mm, we could add a pseudo-keyword tag such as $h (analogous to $t or $j) for use in comments, that would restate the $a statement with the original notation. For example, w3a in the original
set.mm $( Extend wff definition to include 3-way conjunction ('and'). $)
w3a $a wff ( ph /\ ps /\ ch ) $.
would become in the Polish
set.mm $c /\3 $.
$( Extend wff definition to include 3-way conjunction ('and').
$h ` wff ( ph /\ ps /\ ch ) ` $)
w3a $a wff /\3 ph ps ch $.
The new token /\3 would have to be created by the converter if the preferred token has been used (such as /\ for wa), ideally using some reasonable heuristic. (I think Raph's Metamath to Ghilbert translator does something similar, not sure.) But since Polish prefix isn't meant to be directly human-readable it doesn't matter much what the new tokens are called; we could also use a variant of the label like _w3a. The new tokens would be discarded upon conversion back to the original
set.mm.
We would need $h comment tags only for the syntax $a's. This provides enough information so that we can losslessly convert the Polish prefix version back to the original
set.mm. (A slightly tricky problem is how to preserve indentation and line breaks in the original
set.mm's $a/$p/$e math expressions, but I think I have a solution to that.)
Note that proofs would stay exactly the same and don't have to be touched.
If there is a strong demand for this minimalist subset of the Metamath language, in principle our various software tools could be modified so the user would see and interact only in the "human" syntax. However, conversion from
set.mm to Polish
set.mm and back should be reasonably fast as well as lossless, so either one could be used for development and display. (There are a few logicians such as Ted Ulrich who work primarily in Polish notation:
https://web.ics.purdue.edu/~dulrich/Home-page.htm )
Although a conversion program can probably be written without an inordinate amount of effort, I don't have any immediate plans for such a project unless there is a serious demand. I am mainly describing what is possible in principle, if it helps lessen the perception that "the soundness story in current Metamath is rough."
Norm