Closed lemmy closed 2 years ago
@konnov Does Apalache already have folds for bags?
No, we don't. But I think it should be relatively easy to implement them via FoldFunction
.
@muenchnerkindl added a TLA+ operator definition of BagsExt!FoldBag
in https://github.com/tlaplus/CommunityModules/commit/b961f70ef7725b9e30a5457cffe16f90015c0e31. The Java module override for TLC still has to be done.
The module override of the Functions.tla
module should either be immediately applicable like with sequences or at least provide inspiration on how a dedicated module override for BagsExt.tla
would look like.
For testing Java module overrides, a useful trick is to define the pure TLA+ operator with a different name in the test module and assert equality for the pure and overridden operator for various inputs: https://github.com/tlaplus/CommunityModules/blob/b961f70ef7725b9e30a5457cffe16f90015c0e31/tests/FunctionsTests.tla#L30-L34
For reference, the original module override of the Bags.tla
standard module is at https://github.com/tlaplus/tlaplus/blob/master/tlatools/org.lamport.tlatools/src/tlc2/module/Bags.java
@muenchnerkindl noted that we lack fold operators for the Bags.tla module. @konnov Does Apalache already have folds for bags?