strict provable sort wff;
pure sort set;
strict sort class;term wi (ph ps: wff): wff;
term wn (ph: wff): wff;
def wa (ph ps: wff): wff = $ ~(ph -> ~ps) $;infixl wa: $/\$ prec 20;
infixr wi: $->$ prec 25;
prefix wn: $~$ prec 40;
notation cab {x: set} (ph: wff x): class = (${$:0) x ($|$:0) ph ($}$:0);delimiter $ ( ) ~ { } $;|- ( ph -> ( ps -> th ) )Apparently, it is quite easy to write plugins for intellij idea.
I just tried and one day later, I had written lexers and primary parsers for the mm0 and mmu files, with JFlex and GrammarKit (and thanks to mario's answers and the experience gained by writting home made parsers for mm0/mmu),
A few minutes ago, I just pushed accidently my prototype plugin to https://github.com/Lakedaemon/mm0-kotlin-tooling
I did not push the plugin to the market place yet though (because it misses lots of functionnalities, I'll do that later when it is ready)So, I'll probably be able to develop and distribute a fully feature plugin adding mm0 and mmu support to intellij idea (which has a free community version), with the usual intellisense goodness added to it.
This should be a nice alternative to vs-code.There is an issue that must be addressed though :
Intellij idea refuses to open set.mm.mmu outside of raw mode (no syntax highlighting/advanced features) because it is much too big (at 450MB).
Which is quite understandable. But that means that people will have to break mmu (and mm0) files into smaller parts to be ableto work with them confortably.
There is an "import file.mm0;" statement at the top of https://github.com/digama0/mm0/blob/master/examples/string.mm0that could mitigate the issue, by allowing to split files in smaller parts and to reassemble them when veryfing.
BUT the fact that these statements aren't in the mm0 grammar should render vscode and intellij idea unable to work with these files (because parsing these files that hold an invalid statement will fail).
So,it would be nice to have a solution that allows :
- reusing mm0/mmu files (like modules)
- limit their length/split them
- agregate them
Mario recently published a tool that can agregate files with "import at their top".
But that doesn't fix the issue for intellij idea
Maybee, a solution would be to stip the mm0 files from the import statement and have a third filetype (.mmerge)
that holds a structured document telling how to build big mm0/mmu files from smaller parts
You probably know this already, but I've been focusing my user interface stuff on the .mm1 file format. The mmu file format currently doesn't even have a syntax highlighter, although it could without too much trouble (it's just an s-expression). But don't make users write mmu files, that's not nice. That's like asking people to write metamath proofs (the contents of $p $= proof... $.) by hand.
Writing an .mm1 IDE is not a trivial matter, not least because users want many things from an IDE, but now there are two, and they both conform to the LSP specification explicitly so that you can plug them into alternative editors. So if you like IntelliJ idea, see if you can write a plugin that communicates to mm0-rs via the json protocol.
That's what it was designed for. (If you check the marketplace / plugin database, I will bet you can already find a LSP client implementation for intelliJ,
Yep, in my mind this is already a solved problem.
Even for very advanced theorems the resulting mm0 files are only a few hundred KB. The mmb file is much larger, but it is not meant to be edited by a text editor anyway. The mmu file is even larger because it is a textual version of the mmb file, but it is also not meant to be edited by a text editor, and it's rather overwhelming for non-toy problems.
Imports can be used to lop off the "introduction" section of a development and put it in a different file. As of recently, you can now directly import a .mmu file into an mm1 file (mmb import support is coming),
no one likes to read piles of s-expressions
meaning that you could have a small mm1 file that imports set.mm.mmb and then adds a few hundred theorems of your own on top. The imported file will not be rechecked on every keypress, so you get fast response times, and you can write your local development that way.Mario recently published a tool that can agregate files with "import at their top".
But that doesn't fix the issue for intellij ideaMaybee, a solution would be to stip the mm0 files from the import statement and have a third filetype (.mmerge)that holds a structured document telling how to build big mm0/mmu files from smaller partsIt sounds like you are proposing
what the .mm0 files in the examples folder already are, which is to say, mm0 files which are non-conforming because of the addition of import statements, which can be assembled into conforming mm0 files by the aggregation utility.
It is critical that import statements remain a "non-conforming extension" to the mm0 file format, rather than actually part of the spec, because it is extremely difficult to formalize file includes in a reasonable manner, and they aren't needed for scalability at the low level.
(The aggregator is careful to preserve things like formatting when building the mm0 files, so that the output is still readable, yet self contained, because it is the source of truth for the target axiomatization.)
Mario
Hi Mario
Many thanks for the answerYou probably know this already, but I've been focusing my user interface stuff on the .mm1 file format. The mmu file format currently doesn't even have a syntax highlighter, although it could without too much trouble (it's just an s-expression). But don't make users write mmu files, that's not nice. That's like asking people to write metamath proofs (the contents of $p $= proof... $.) by hand.Yes. I'll remove the part about editing/looking at mmu files and concentrate on mm0 (I experimented first on mmu because the grammar is easier)Before I remove it, could you please have a look at the mmu lexer rules and the mmu primary parser bnfAnd use those to update the specs of mmu in the official mm0 repository, please.That way, it'll be easier for other developers to adopt mm0 and build their own tools
That's what it was designed for. (If you check the marketplace / plugin database, I will bet you can already find a LSP client implementation for intelliJ,Good, it'll make things easier. I am just concerned about one bit :the plugin will probably have to ship native binaries (for multiple platforms). So, it'll be at best more cumbersome that a java/kotlin/groovy/scala solution that runs on the jvm already shipped with intellij idea.
But if it is doable, I'll do it.Yep, in my mind this is already a solved problem.I knew it. :)You are a bit like Fermat ("I have just solved a very important problem for mankind") except- he wrote short esoteric blog posts in the margin of his proofs while you write short proofs in your esoteric blog posts
- that we can wring answers out of you and implement those solutions in a matter of days instead of centuries, which is definately nice. ;)Mmmh. This is niceEven for very advanced theorems the resulting mm0 files are only a few hundred KB. The mmb file is much larger, but it is not meant to be edited by a text editor anyway. The mmu file is even larger because it is a textual version of the mmb file, but it is also not meant to be edited by a text editor, and it's rather overwhelming for non-toy problems.yes. The only people who will want to have a look at mmu/mmb files are probably software developers that want to implement mm0 backed features.
The rest of humanity don't need to look inside that. It just needs to work (as excpected).
I'm not sure I'll ever want to go in the mm1 direction mostly becauseno one likes to read piles of s-expressionsand selection doesn't seem to look favorably on Lisp-backed languages (which might just be a corollary of the first quote)I try to be open minded but I think It'll take a lot of convinving to get me to even open a mm1 file.
Maybee, a solution would be to stip the mm0 files from the import statement and have a third filetype (.mmerge)that holds a structured document telling how to build big mm0/mmu files from smaller partsIt sounds like you are proposingActually, I'm not proposing. I mostly want to talk about the issue to know what should be best done about it, so that we can reap benefits in the future (and not shed tears later)
- You have pondered a long long time and you did a marvelous job at designing mm0, but most of the explanations are still in your mind.
I need to know the reasoning behind things before I implement stuff, to do a good job (and also, because I'm curious and not a robot).
- it gives people (including me) the opportunity to speak their minds, suggest ideas, give advice and maybe find an even better solution
(The aggregator is careful to preserve things like formatting when building the mm0 files, so that the output is still readable, yet self contained, because it is the source of truth for the target axiomatization.)mm0/mmu/mmb files excell at what they where designed for.Imo, aggregating is an external concern and shouldn't touch mm0/mmu/mmb files and it would be nice to allow everyone (including non mm1 believers) to do the aggregation themselves.
So, it would be nice to design a very simple and open solution that would elegantly handle the issue.
Also, there is the issue of proof authoring (which is a fundamental part of getting mm0 to succeed). I'm not saying that you should solve proof authoring too.
But again it would be nice if everything was in place so that other people could have the basic core features to be able to write authoring tools on top of mm0/mmb.
This is quite a lengthy subjects so I'll just throw subjects around in later posts but we already spoke of :
1) spliting mm0 files in short parts (looks like you are ok with that)
2) having custom mm0 files with selected theorems (looks like you already did it)3) aggregating mm0 files together (already brushed)somehow this reminds me of libraries and software development and screams package managers. :)
4) having a standard file format to allow spec/proof conversion between theorem provers (You already did that)Yet, you sayA production quality verifier should probably use a binary file format, but the information contained in the file should be about the samewhich somewhat implies that you don't intend mmb to become an interchange format, as it would be best for the binary formats to get the best of the platform/endianness it is target at for performances reasons, I guess
So, do you intend .mmu files are what will be used to exchange proofs between people, worldwide ?
Say, you exchange .mm0 files (in a contest) and the someone A writes proofA on his linux pc, with mephistolus
he sends the exported .mmu proof to someoneB on his windows/amiga/weird endianness box to read the proof and import it in hol (or whatever) ?
Quite satisfying but this raises a question :
The parser of mm0 is great at parsing stuff with binary operators and turns things like1 + 2 intoa tree of the form+ {12}Yet Metamath was designed around co, that takes 3 classes A B C to define ( A B C )so the Metamath for the same tree isco {1+2}
I tried to workaround that by adding a definitiondef mm0AddC(a b: class): class = $(co a caddc b)$;that is like a bridge between the 2 trees.But now, this made me think1) metamath trees are unique but not mm0 trees, because you can have definitions that allow to express the same tree in different mannersAs you can see 1 + 2 + 3 can be represented by both trees in mm0 :just terms (no definition, which are expended)co {co {1+2}+3}and (with definition)mm0AddC {mm0AddC {c1c2}c3}
2. set.mm.mm0 might not be the correct way to express maths in mm0 (ok, I'm naive).
It provides nice tests for the parsers/verifiers but eventually math will have to be rewritten in mm0For example, maybee the 3 arguments structs like co should disappear.They make it nice to have equalities like A=B, C= D, E=F -> ( A C E ) = ( C D F ) for a lot of operators but they don't play well with mm0 parser/treesthe logical stuff (and or, not)/2 args stuff should be simpler to migrate to mm0
But tools that refactor the mm theory/proofs into mm0 friendly expression should probably be written/used to translate set.mm into a more working condition for mm0Probably quite a lot of things will have to change (And I had this hope to implement mephistolus on mm0 in 2 months, ahah, I'm so dumb...)
It will be hard as refactoring set.mm.mm0 requires refactoring the proof at the same time, which is not easy at a point in time where there aren't that many tools available3. I'm wondering how set.mm should be turned into mm0. What are the major implementation differences ?
This is correct. I have said on a few occasions that the metamath and mm0 notation systems are incompatible, and this is why. In MM0, every piece of notation is associated to a syntax constructor, while in metamath syntax constructors are associated to productions in a global CFG that need not have any particular characteristics.
I would say: MM0 trees are unique; these are different trees, that happen to be provably equal.
Metamath does not have unique trees in the sense that a given token string can have two parses (although set.mm doesn't have this pathology).
You have created these two trees by using different parser configurations for the same string, which is of course fine because the parser configuration (the sequence of "infix", "notation", etc) is fixed for a given database.
This is "mm0AddC" is another way to get metamath-ish notations inside MM0, and probably what I would do in a hand translation. It has some drawbacks, though. Because the terms are not literally the same as the corresponding metamath terms, a bunch of additional proofs have to be inserted, and it's not completely trivial to work out where those proofs should go.
What's more, in metamath because there is only one operation, "co", involved, there is only one theorem "opeq2d" that gets used for a wide variety of operations, for example it can prove "B = C -> A + B = A + C" and also "B = C -> A - B = A - C". In MM0, these are two different syntax constructor, rather than the same syntax constructor with a different middle argument, so you need different theorems for these two cases.
(MM1 will automatically generate all such equality theorems so the user pain around this is minimal.)
Actually, I find MM0 much nicer to use than metamath when it comes to functions with 3 or more arguments, which come up a lot in the computer science type applications I have been working on. That's because there is a notation that requires no "notation", the default notation that everything gets, which is "foo x y z". This generalizes trivially to any number of arguments and does not require any parser directives, so it is the natural option for big and complicated predicates with many arguments. In metamath you would have to define a new notation for this, and the syntax is not so great; for functions you have the options of ( foo ` <. a , b , c >. ) (which doesn't generalize past 3), ( foo ` <. a , <. b , c >. >. ), ( foo ` <" a b c "> ), or ( ( ( foo ` a ) ` b ) ` c ) (which doesn't always work for class functions). The most generally applicable form is ( foo ` <. a , <. b , c >. >. ), but the syntax is the worst among all the options. (The <" A B ... Z "> notation was created specifically for this use case, but you still have to select the right constructor depending on how many arguments you have, and the notation gets verbose again once you get past 8 arguments.) You can also do funny things with arguments on the left and right with stuff like ( c ( a foo b ) d ) to make it more compact but this is pretty mind bending to read.
But tools that refactor the mm theory/proofs into mm0 friendly expression should probably be written/used to translate set.mm into a more working condition for mm0Probably quite a lot of things will have to change (And I had this hope to implement mephistolus on mm0 in 2 months, ahah, I'm so dumb...)
It will be hard as refactoring set.mm.mm0 requires refactoring the proof at the same time, which is not easy at a point in time where there aren't that many tools available3. I'm wondering how set.mm should be turned into mm0. What are the major implementation differences ?Well, I think you've already seen the answer.
The logical part is a one time cost; there is some work on the translator and then boom, you've got megabytes of raw MM0 to play with. That's already happened, but as you can see this leaves a lot to be desired when it comes to presentation. If you analyze the notations with an eye for the way set.mm writes things, you can probably reverse engineer a good number of MM0 notations. For example, things like df-an are easy (although you would have to specify the precedence and associativity manually, because metamath doesn't have any information to give in that regard). Some notations would have to change, like df-al and df-ral overlap their first symbol, which is not allowed. So for an automatic translation you have to somehow stick disambiguating marks on things without it looking terrible. And then there are notations "via co", which are difficult because you don't know which operations are going to be used in advance. If you want to declare a new constructor like your "mm0AddC" for each operation, you have to identify that df-pl, whose definition is |- + = ..., is a class that is meant to be used as a binary operation, whereas "|- 0 = ..." is a constant, not a binary operation, and "|- sin = ..." is a unary operation. One cue is that the binary operations are usually declared using df-mpt2, but not always. But there will always be "funny terms" like ( a ( x e. A , y e. B |-> C ) b ) that will actually be using co directly, so there is a fallback option if detection doesn't work out, and this can be viewed as an optimization.
So far, I have only changed c1 into 1 (same for c2, c3, c4, c5, c6, c7, c8, c10). Which requiresto replace every instance of "c1" in the mmu and mm0 files with "1" (some work, but not very hard)
and added simple notations for the logical operators (this is even easier)but now, I'll try to do something hard :- either replace the term for logical or with a definition (which means refactoring lots of proofs)- or replacing the co usage for +, with using a term (which probably means more refactoring)
I am not at all sure that I'll be able to pull this off. I do not know how long it will take me either.
(I only know that if I can pull this off, I'll be able to improve stuff a lot)I'll probably go with replacing the or term with a definition (which will make me able to write conversibility proof, a necessary requirement for me).
Wish me luck !Best regards,
Olivierps : I'll soon publish my patched mm0/mmu files (in case someone is interested) ans also my mm0/mmu parsers (first).
Those can/should still be improved but it can be done later.
Stay home and stay safe ! :)
--
You received this message because you are subscribed to the Google Groups "Metamath" group.
To unsubscribe from this group and stop receiving emails from it, send an email to metamath+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/metamath/65485950-3987-4be2-8746-cf1e93df5267%40googlegroups.com.
On Fri, Apr 3, 2020 at 12:12 PM Olivier Binda <olus....@gmail.com> wrote:So far, I have only changed c1 into 1 (same for c2, c3, c4, c5, c6, c7, c8, c10). Which requiresto replace every instance of "c1" in the mmu and mm0 files with "1" (some work, but not very hard)Note that "1" is not a valid mm0 identifier. You have to define "1" as a notation for a constant with a valid identifier, such as "c1".
and added simple notations for the logical operators (this is even easier)
but now, I'll try to do something hard :- either replace the term for logical or with a definition (which means refactoring lots of proofs)- or replacing the co usage for +, with using a term (which probably means more refactoring)The MM0 pretty printer already knows how to print notations, so all you would have to do is to add a notation for wo. But it would have to happen between reading the incoming .mm file and producing the output, that is, inside mm0-hs, so that is on me to some extent. It needs to somehow accept configuration information to guide the process, and passing that by the command line would be very clunky. The internal metamath parser already knows how to read $j commands, so one option would be to add a new $j command declaring the notation.
I am not at all sure that I'll be able to pull this off. I do not know how long it will take me either.
(I only know that if I can pull this off, I'll be able to improve stuff a lot)I'll probably go with replacing the or term with a definition (which will make me able to write conversibility proof, a necessary requirement for me).Doing this alone is pretty easy, especially if you are doing manual fixups on the output file. Put the definition of or in for "def wo", and prove df_or by reflexivity (after unfolding)
Mario.
--
Wish me luck !Best regards,
Olivierps : I'll soon publish my patched mm0/mmu files (in case someone is interested) ans also my mm0/mmu parsers (first).
Those can/should still be improved but it can be done later.
Stay home and stay safe ! :)
You received this message because you are subscribed to the Google Groups "Metamath" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meta...@googlegroups.com.
I guess that the restriction on id is this way so that we can do nice stuff with notations (mostly with numbers).
For example, at some point, I plan to allow users to write 1283 and to have that (maybe in a preprocessing step) turned into (; ; ; 1 2 8 3 ) because normal users will want to use numbers the way they are used to
but now, I'll try to do something hard :- either replace the term for logical or with a definition (which means refactoring lots of proofs)- or replacing the co usage for +, with using a term (which probably means more refactoring)The MM0 pretty printer already knows how to print notations, so all you would have to do is to add a notation for wo. But it would have to happen between reading the incoming .mm file and producing the output, that is, inside mm0-hs, so that is on me to some extent. It needs to somehow accept configuration information to guide the process, and passing that by the command line would be very clunky. The internal metamath parser already knows how to read $j commands, so one option would be to add a new $j command declaring the notation.You hint that it could be done with mm0-hs. Ok.
Still, I don't want to rely on that. I need to be able to do that myself, because Mephistolus needs it.So, I will only rely on mm0-hs to translate mm stuff into basic mm0-stuff