-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse trees are in source order instead of argument order #170
Comments
Interesting - In See the comment and the code for the I assume that you need something like this - or maybe even exactly this function. |
The trees are not an internal detail, they are the output of parsing. Any tool that wants to use the parser will want the resulting syntax objects after parsing, as a tree, or otherwise what was the point of the parse? And the tree consists of nodes and those nodes are syntax axioms which have a definite order for their arguments which is not lexical order. I have a fix for the parser code in #173.
When I said "source" order, I mean textual left-to-right parsing order (what the parser currently does), which is not the same as "frame" order (which is what I believe it should be doing). I am not yet sure what to do about this function in #173.
By the way, this also caused difficulties for me, which is one of the reasons I needed to use a branch in order to get at the tree data. I don't think I want |
Until now it was sufficient for the tools I wrote to have an "opaque" tree which could be matched against other trees and where variables could be substituted with other trees. I needed parsing and those operations to be as quick as possible, and the move back to the "proof-order" world occurred only once, if a proof was found, and after the proof was build.
Sorry about that!
And what do you do with that structure? In my use cases until now, I have been using Indeed I agree that if the formula needed to be accessed, one might expect the "frame" order (sorry for the confusion of naming the children ordering, I wrote "source order" for "frame order" earlier). But that "frame" order is especially important for building proofs, which PS. I've read some of the MM Hammer source code and it seems you maybe first want to output some LISP style formula to be used as an input for the external tools. Am I correct? |
For that, I don't see why you need a tree at all. Metamath already supports substitution and matching of formulas, without trees.
Yes, that is the use case at the moment. mm-hammer is an adaptation of the translation from MM to MM0, which basically needs to insert parentheses in MM theorem statements and turn them into a lispish format, where the applications of course need to be consistent with the declaration of the term constructor. I'm looking at |
Metamath does, but metamath-knife did not.
I believe with your proposal the
|
#173 now implements an updated and improved version of |
Not all metamath term constructors take their arguments in source order. An important example is
wal $p A. x ph $.
, which hasx
beforeph
in source order but becausewph $f wff ph $.
is declared beforevx $f setvar x $.
, the actual argument order iswal(ph, x)
, which is visible in syntax proofs in the database.Currently,
grammar.rs
does not handle this situation correctly, and always adds the arguments to the tree in source order, resulting in ill formed trees of the formwal(x, ph)
. This is the source of one of the errors reported at digama0/mm-hammer#1 .cc: @tirix
The text was updated successfully, but these errors were encountered: