-
Notifications
You must be signed in to change notification settings - Fork 24
Make the LSP independent of level assignment. #186
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
base: updated_enabled_cdot
Are you sure you want to change the base?
Conversation
The TLAPM parser has a level-checker? |
It has, but I'm unsure how complete it is. See e.g. https://github.com/tlaplus/tlapm/blob/d8e2a2135063fbb0bd6a4fb3af7bba46951059c8/src/expr/e_levels.ml |
Would you leave your thoughts on tlaplus/rfcs#16 since you know much more about the TLAPM parser than anyone else? |
Thanks for starting that discussion. I will try to join it, but my knowledge of that parser is limited. |
The fingerprint calculation reverted to is_const (as it is now done in the main branch) instead of get_level to make the fingerprint calculation independent of the level assignment. This is done to avoid having level assignments on the critical path in the LSP, as it is too slow. In my case, it took 30 seconds to calculate the levels, which blocks subsequent LSP commands. Signed-off-by: Karolis Petrauskas <[email protected]>
d8e2a21
to
0ae62a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge this fix, I think it is the last thing holding up #148. We will revert this change when we figure out what's wrong with level inference.
Thanks @damiendoligez. I will spend another few evenings on the level checking performance, and if nothing good happens, I will merge this PR. |
@kape1395 worth noting the TLA+ Foundation is funding me to switch TLAPM over to the Java parser (SANY) in the near future, which will take care of these level-checking performance issues from the perspective of TLAPM. However, it makes sense to spin out the TLAPM parser into its own repo (it's still quite a good parser and worth keeping for its own sake!) so you can have the choice of continuing to use the TLAPM parser or using SANY. The work will involve translating SANY's parse tree into the parse tree format used by TLAPM so these changes should be transparent to you. |
Why is it important to preserve the interface between TLAPM and its legacy parser? What is it buying us? |
All the transformations to the backend provers are defined over the existing parse tree format, is my current understanding. |
Understood - there’s no issue with refactoring the parse tree format, but it will require refactoring some of the transformations. To minimize the risk of regressions, such refactoring should be avoided unless justified. |
I don't think we need to keep the existing tlapm parser if the new one is integrated and works well. Where can I put my wishes (would become requirements, if agreed) for the parser integration? Preliminary:
Also, it is unclear to me what happens to the expression levels when definitions in an expression are expanded. Don't we need to recalculate the levels? Does the SANY parser handle that? |
Do you mean operators? Basically how SANY handles that is if you have an operator like: prime(x) == x' then it puts a constraint on the parameter There's an even more complicated analysis that needs to be done for higher-order operators, as in operators accepting other operators as parameters. Error 4272 "higher order operator parameter level constraint not met" involves the level checker defining minimum levels for parameters. Here's an input that would trigger it: VARIABLE v
op(F(_)) == F(v')
op2 == op(') This one is a bit confusing. Basically when higher-order operators are used, the level-checker needs to determine the max/min levels of arguments they can accept. It does this by looking at how the higher-order operators are used. In this case, You can see a formal spec of the level checking process here. SANY also runs a complementary analysis trying to ensure formulas are stuttering-insensitive. This is incomplete, as documented in bug tlaplus/tlaplus#1160 |
Nit: TLA+ is a first-order logic. It is not higher-order, where operators can be treated as values. You may pass an operator to another operator, but you e.g. cannot quantify over operators. |
@lemmy good point. What do you think is a good term for the parameter of these not-higher-order-ops? I've seen "operator parameter parameter" a few times in the codebase which I don't really like. |
I'm not aware a dedicated terminology. |
The fingerprint calculation reverted to is_const (as it is now done in the main branch) instead of get_level to make the fingerprint calculation independent of the level assignment. This is done to avoid having level assignments on the critical path in the LSP, as it is too slow. In my case, it took 30 seconds to calculate the levels, which blocks subsequent LSP commands.