-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add Reduce
operator to Functions
#35
Comments
We had a discussion that the current Reduce operator from FiniteSetsEx is a bit restrictive: it works only on functions with integer domain but it also works on sets. On the other hand, it is sometimes needed not to reduce on the full domain, as @lemmy's example from the ewd998 formalization shows. I have added the operators to a branch in my fork of the community modules. What do you think? |
As mentioned in today's call, I suggest moving the functions-related operators out of Speaking of comments, the format that is the best support by tools, i.e., IDE is: OpDecl(params) ==
(************)
(* comments *)
(* comments *)
(* comments *)
(************)
TheOperatorDefinition I'd also suggest adding an example invocation in the comment as in: CommunityModules/modules/FiniteSetsExt.tla Lines 71 to 75 in 4337afb
Lastly, there is a precedence of operator aliasing: CommunityModules/modules/SequencesExt.tla Lines 34 to 46 in 4337afb
PS: TLC takes 2-3 minutes on a laptop to check EWD998 for |
CommunityModules/modules/Functions.tla Lines 10 to 13 in 4337afb
|
In fact, FoldMap and friends do not use any operator defined in either Functions or FiniteSets, so I believe it would be best to place them in a separate module. Also, please remove the comment in the definition of FoldSet that refers to the operator ReduceSet that will disappear. For the rest, I agree with @lemmy's comments. And I don't know if "FoldMap" is a good name? |
WRT the functions/sequence-based folds, what about non-associative operators (fold left vs. right)? Do we want to open that can of worms? |
I'd be in favor for having those for sequences (or perhaps for functions whose domain is an interval of integers). I don't think it's worth having them for arbitrary functions: you need a total order on the domain for those notions to make sense, so doing it in full generality would require auxiliary definitions for little gain in expressiveness. |
I also think that we could place all fold-like operators in a separate module, like |
Given that we have |
True. Would |
I have created one Folds module for the complicated MapThenFoldSet definition that probably shouldn't be used directly (see comment there) and put the changes into a pull request draft that it's easier to compare. I don't think it's ready yet - the least I'm missing is test cases. I'm wondering two things:
|
I have added the FoldLeft / FoldRight definitions to SequencesExt (and removed ReduceSeq) |
/cc @muenchnerkindl @konnov @quicquid
The text was updated successfully, but these errors were encountered: