Skip to content
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

Fix handling of constant operators #2389

Merged
merged 4 commits into from
Mar 6, 2023

Conversation

BGR360
Copy link
Contributor

@BGR360 BGR360 commented Jan 29, 2023

Fixes #2388
Closes #709

If this approach seems good to folks, I can clean it up and make this a not-so-draft PR. This fixes the issue for the two specs I posted in the original issue, but I have no idea if it's a really robust fix or not.

  • Tests added for any new code
  • Ran make fmt-fix (or had formatting run automatically on all files edited)
  • Documentation added for any new functionality
  • Entries added to ./unreleased/ for any new functionality

@BGR360 BGR360 changed the title Quick and dirty fix for constant operators Fix handling of constant operators Jan 29, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jan 29, 2023

Codecov Report

Merging #2389 (3b6b03e) into main (64ca9bc) will decrease coverage by 0.02%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##             main    #2389      +/-   ##
==========================================
- Coverage   78.35%   78.34%   -0.02%     
==========================================
  Files         441      441              
  Lines       15387    15388       +1     
  Branches     2464     2439      -25     
==========================================
- Hits        12057    12056       -1     
- Misses       3330     3332       +2     
Impacted Files Coverage Δ
...at/forsyte/apalache/tla/imp/OpApplTranslator.scala 94.88% <50.00%> (-0.33%) ⬇️
...a/at/forsyte/apalache/tla/lir/TlaLevelFinder.scala 93.75% <0.00%> (-2.09%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@thpani thpani self-requested a review January 30, 2023 12:37
@thpani thpani self-assigned this Jan 30, 2023
@konnov
Copy link
Collaborator

konnov commented Jan 30, 2023

That's a neat solution! I thought it would require more effort to translate constant operators, though it has been a while since I have look at SanyImporter.

It looks good to me. The only thing is that logger.debug may produce lots of debugging messages. Perhaps, it's worth changing the logging level to TRACE. Could you also add a changelog entry. Apart from that, looks like to ready for review for me.

@Kukovec
Copy link
Collaborator

Kukovec commented Jan 30, 2023

Also:
closes #709

@BGR360
Copy link
Contributor Author

BGR360 commented Feb 1, 2023

How does one enable TRACE-level logging when trying to debug things? The only documented thing I found was the --debug CLI flag.

Regardless, I didn't really intend to keep those log messages in. I just pushed the PR late at night as soon as I had fixed my problem lol

Copy link
Collaborator

@thpani thpani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @BGR360, thanks a lot for the excellent contribution!

If we can address the open comments, I think this is good to be merged!

Ben, would you like to see this across the finish line?

@thpani
Copy link
Collaborator

thpani commented Feb 2, 2023

How does one enable TRACE-level logging when trying to debug things? The only documented thing I found was the --debug CLI flag.

Logback configuration is programmatic in LogbackConfigurator. We're current cutting off messages at DEBUG:

https://github.com/informalsystems/apalache/blob/4f9c17d86bf564e18f1a079d17a1d5b3d08820e8/mod-infra/src/main/scala/at/forsyte/apalache/infra/log/LogbackConfigurator.scala#L47-L49

But I think it's fine to remove these log messages before merging, as you suggested.

@BGR360
Copy link
Contributor Author

BGR360 commented Feb 3, 2023

Thanks for the review @thpani !

Ben, would you like to see this across the finish line?

I'm happy to, but it'll be on my own time, whenever I get to it. Perhaps this weekend. If you're offering to take it off my hands and push it through yourself, be my guest!!

Though I think this PR can't be called complete until we test whether it actually functions as expected (that you can substitute the higher-order operator when instantiating a spec and it works properly). Currently I've only tested the typechecking.

@thpani
Copy link
Collaborator

thpani commented Feb 10, 2023

I'm happy to, but it'll be on my own time, whenever I get to it.

Let's do it! This is not super urgent on our side, and we're happy to see external contributions 😃
Let us know if you need any help or guidance @BGR360!

this PR can't be called complete until we test whether it actually functions as expected

Ah yes, I actually did a full instantiation of your integration test to make sure it passes model-checking. We should include something similar in this PR!

@BGR360 BGR360 force-pushed the issue-2388-const-opers branch from ae58fd7 to fadf782 Compare March 4, 2023 22:55
@BGR360 BGR360 marked this pull request as ready for review March 4, 2023 23:00
@BGR360 BGR360 requested a review from shonfeder as a code owner March 4, 2023 23:00
@thpani thpani requested review from thpani and konnov March 6, 2023 08:43
@thpani thpani force-pushed the issue-2388-const-opers branch from fadf782 to 5622ec9 Compare March 6, 2023 08:44
thpani added 2 commits March 6, 2023 11:12
This is to avoid confusion, we already supported 0th-order `CONSTANT`s /
their instantiation with 0th-order operators before.
@thpani thpani requested review from Kukovec and removed request for thpani March 6, 2023 10:38
@thpani
Copy link
Collaborator

thpani commented Mar 6, 2023

This is awesome, thanks a lot Ben!

I've made some small polishing changes, so @konnov @Kukovec PTAL!

(I also tried to add a test for a 2nd-order CONSTANT, but it does not seem to parse through SANY. So I'd leave it at this.)

@thpani thpani merged commit 830f96e into apalache-mc:main Mar 6, 2023
@BGR360
Copy link
Contributor Author

BGR360 commented Mar 6, 2023

(I also tried to add a test for a 2nd-order CONSTANT, but it does not seem to parse through SANY. So I'd leave it at this.)

@thpani What do you mean by this? Something like this?

CONSTANTS
    \* @type: (Int, (Int) => Bool) => Bool;
    MapInt(_, MapFn(_))

@konnov
Copy link
Collaborator

konnov commented Mar 6, 2023

This is awesome, thanks a lot Ben!

I've made some small polishing changes, so @konnov @Kukovec PTAL!

Looks great! Thanks a lot @BGR360 and @thpani!

(I also tried to add a test for a 2nd-order CONSTANT, but it does not seem to parse through SANY. So I'd leave it at this.)

I vaguely recall that 2nd order operators are not supported in TLA+.

@apalache-bot apalache-bot mentioned this pull request Mar 6, 2023
@thpani
Copy link
Collaborator

thpani commented Mar 7, 2023

@thpani What do you mean by this? Something like this?

CONSTANTS
    \* @type: (Int, (Int) => Bool) => Bool;
    MapInt(_, MapFn(_))

Yes, exactly!

@thpani
Copy link
Collaborator

thpani commented Mar 7, 2023

(I also tried to add a test for a 2nd-order CONSTANT, but it does not seem to parse through SANY. So I'd leave it at this.)

I vaguely recall that 2nd order operators are not supported in TLA+.

They're defined in Specifying Systems, but idk about tool support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apalache does not support operators as CONSTANTS [FEATURE] Higher-order constants
5 participants