# Add varargs methods of \`any\`, \`all\`, and \`count\`

**URL:** <https://discourse.julialang.org/t/add-varargs-methods-of-any-all-and-count/95072>\
**Category:** Internals & Design\
**Tags:** count, all, any, varargs\
**Created:** [February 23, 2023, 11:13am UTC](https://discourse.julialang.org/t/add-varargs-methods-of-any-all-and-count/95072 "2023-02-23T11:13:07Z")\
**Posts on this page:** 1\
**Showing post:** 27

<div class="post-metadata">

**Author:** ![uniment](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uniment/32/24532_2.png) [@uniment](https://discourse.julialang.org/u/uniment)\
**Post date:** [February 26, 2023, 7:10am UTC](https://discourse.julialang.org/t/add-varargs-methods-of-any-all-and-count/95072/27 "2023-02-26T07:10:26Z")

</div>

> [@jar1](#):
>
> “unified algebra” essays [1](http://www.cs.toronto.edu/~hehner/BAUA.pdf), [2](https://www.cs.utoronto.ca/~hehner/UA.pdf)

(On-topic:)

This unified algebra has some major differences from Julia’s semantics, that I don’t see a way to resolve anytime soon. For example, his notion of a _function_ involves tightly packaging the domain with the expression that operates on it—in some ways it’s conceptually closer to a Julia `Generator` than a `Function`, a fact which he leverages aggressively. He also expresses multiple-argument functions as currying. Both of these are difficult to fit into Julia’s multiple-dispatch paradigm, and currying is incompatible with vararg functions altogether.

That said, even though he uses \uparrow (`max`) and \downarrow (`min`) for \wedge (`&`) and \vee (`|`), I still see the OP proposal as _not opposed to_ his algebra (aside from the currying thing, of course).

Instead of writing \sum\_{x\in D}f(x) and \forall x\in D, p(x), he promotes overloading binary operators such that when taking a function as their argument they mapreduce over its domain—so we would instead write +\langle x : D\rightarrow f\,x\rangle and \downarrow\langle x : D \rightarrow p \, x\rangle. In-so-doing, by ejecting the former notations from algebra, he relegates them to informal (or at least, less-formal) uses such as common language—where we are free to do as we wish.

In other words, because instead of `sum(f, D)` and `all(p, D)` he promotes something more akin to `mapreduce(f, +, D)` and `mapreduce(p, min, D)`, by his proposal the former functions become somewhat untethered from the rigors of algebraic discipline and are free to take on common-language behaviors outside of algebraists’ jurisdiction. So he should likely offer no objection to vararg methods of `any` and `all`—he shouldn’t care.

(Off-topic rant:)

Wow, I wish I had seen these essays years ago; thanks for introducing me to them! This is a refreshing take on how algebra should be formulated, especially (for me) Boolean algebra. From the start, I disliked Boolean algebra—learning it in college was a chore because it felt unintuitive and clumsy; somehow it felt like the professor must be doing something wrong. Since then I learned to accept and embrace it, but that’s likely just a symptom of learned helplessness and Stockholm syndrome.

The proposed binary algebra, using \top for \infty and truth, \bot for -\infty and falsity, and \uparrow and \downarrow for \vee and \wedge, is much more intuitive (and the operator precedences make more sense, considering their distributivity). To an analog circuit designer, it’s basic knowledge that making a binary signal out of a continuous one requires _infinite gain_, so it should’ve been obvious. And for anyone who’s uncomfortable with infinities, it should also cause discomfort with the idea of attainability of certain truth—a development which I think is a net positive. I also find myself attracted to the idea of obsoleting Kleene algebra, and a unified syntax for sets, unions, intersections, and the like.

I would like to learn more about this algebra. For example: How does he propose to write integrals? How shall I visualize a binary probability mass function? What all has been reimagined from this perspective in the world of probability? It’s almost a complete rewrite of mathematics from the ground up, so there’s a lot to think about. I want to see some familiar derivations (of, say, some Fourier transforms) rewritten with its syntax.

Can I entice you to start a thread imagining a future Julia that incorporates some of these ideas? Perhaps a Julia 2.0 could throw `InexactError`s when attempting to convert an `Int` to a `Bool`, and have `Base.isless(::Integer, b::Bool) = b ? true : false`? Treating `true` as numerical `1` does feel like a C-ism that maybe should be a relic of a distant past when compilers weren’t as smart, same as 0-based indexing (😉). And reducing functions like `Base.:+(g::Generator)` and `Base.:↑(g::Generator)` are pretty easy to do.

Also: I have a newborn daughter. Do you know how to find schools that teach this algebra, so that by the time she reaches puberty she’s well-versed in Hehner’s binary algebra? She shouldn’t have to suffer through the insults of Boole.

---

_[View the full topic](https://discourse.julialang.org/t/add-varargs-methods-of-any-all-and-count/95072)._
