# What is the significance of the precedence of a semiring/ ring operations?

In general, a semiring/ring is equipped with two distinct binary operations, namely addition $$(+)$$ and multiplication $$(×)$$ , where in most of the cases, multiplication distributes over addition and in such a case, the multiplication is said to have higher precedence over the addition (why?).

There are also several counter examples of semirings in which addition distributes over multiplication as well as multiplication distributes over addition in a semiring. For example, if $$P(S)$$ is the power set of $$S$$, then $$(P(S),\ \cup,\ \cap)$$ is a semiring in which $$\cup$$ distributes over $$\cap\$$ as well as $$\cap\$$ distributes over $$\cup\$$. Here, it seems that both $$\cup\$$ and $$\cap\$$ have same precedence level.

My question is: what is the theoretical/practical significance of precedence of the binary operations in a semiring /ring?

• It’s just convenience to avoid parentheses overload. – Randall Feb 27 '19 at 12:21
• I think the question is more than about parentheses. I think it is about the asymmetry of the distributive axiom. It is indeed asymmetric, but I don't think the asymmetry is really accurately described as precedence of operations. – rschwieb Feb 27 '19 at 15:04
• @rschwieb yes, you are right. But i was thinking of this in a bit different way. Like, how symmetricity or asymmetricity of operations matters in compuations..etc. thank you. – gete Feb 27 '19 at 15:20
• @gete OK, well I think I understood your question correctly, and I think I gave a good solution, but I do apologize that I apparently cannot compress it into something short. I hope this doesn't deter you from considering my idea. Thanks. – rschwieb Feb 27 '19 at 16:22
• @rschweib Well that's good. It helped me. Ok, could we ask for personal emails in this forum? I would be really sorry if my query was inappropriate. Thanks – gete Feb 27 '19 at 16:39

There is absolutely no relation between identities that may or may not be satisfied (like distributivity) and operator precedence. It might just be that changing precedence could change the identity that a certain sequence of symbols represents into another identity, which could then of course change its validity.

Precedence is a purely syntactic convention; it just states that in some expressions that are not fully parenthesised, implicit parentheses are to be inserted according to certain rules to remove the ambiguity. When we talk about an identity, this grouping is assumed to have already been done; we could write only fully parenthesised expressions in the identity, but as long as precedence rules are agreed upon, it is acceptable (and often more readable) to use not fully parenthesised expressions with the same meaning instead. Inserting implicit parentheses explicitly does not change an identity (just its textual representation), but changing the rules of where those implicit parentheses should go may change an identity (unless it was already fully parenthesised).

## Not really an issue of precedence

I'd like to note that distributivity has this asymmetry you observed, it is not really a precedence in the sense of determining what operations come first.

If you look at it, in order to compute $$a(b+c)$$ you would have to evaluate $$b+c$$ first, then $$a\cdot (b+c)$$ second.

On the other hand, in $$ab+ac$$ you are forced to evaluate $$ab$$ and $$ac$$ first, then their sum.

In one case addition is at the fore, and in the other case multiplication is at the fore. The number of operations required reflects a bit of the asymmetry in distributivity. But ultimately both operations had their chance to "be first."

## An idea about where the asymmetry comes from

This is an intermediate use of category theory, but it might help.

One way that might help to see the relationship between the two operations is this description of a ring:

A ring (with identity) is a monoid in the category of abelian groups.

To understand this, you have to understand how a monoid shows up in category theory: a monoid is a category with a single object.

To say that it is "in" the category of abelian groups means that its single object $$A$$ is an abelian group, and the "elements" of the monoid are the abelian group morphisms $$A\to A$$. The axiom of distributivity is just a consequence of the morphisms being abelian group homomorphisms:

$$(a(b+c))(x):=a((b+c)(x)):=a(b(x)+c(x))=a(b(x))+a(c(x)):=(ab)(x)+(ac)(x):=(ab+ac)(x)$$.

The one $$=$$ in the middle there is where we use additivity of the homomophisms, and the rest are just the definitions of homomorphism compositions and sums.

Now, taking this analogy over to semirings, the correct thing is probably

A semiring (with identity) is a monoid in the category of abelian semigroups with an absorbing element.

Now, one idea would be to stand this picture of a ring on its head by looking at

A group in the category of abelian monoids.

As far as I know, this is completely possible, although possibly not all that useful. A group in a category is a monoid in a category described as above, except that all of its morphisms have inverses. The group is a single object of the category of monoids (call it $$M$$) and the "elements" of the group are monoid homomorphisms $$M\to M$$. In this case, the group operation (composition in the category) would distribute over the monoid operation.

We could also try

An abelian group in the category of monoids

which would entail all the monoid morphisms commuting with each other. In that case, the additively written commutative operation would be distributing over the multiplicatively written monoid operation.

With a little work, the example you gave of two operations distributing over each other can also be explained categorically. I think it might be:

An idempotent monoid in the category of idempotent monoids.

(Probably you need to add some extra condition to get the operations to be fully symmetric? I don't know for sure.)

I haven't thought it through, but in the end I would expect it to be similar to the above, but with the extra property that the category is self-dual in some sense. The duality would make the symmetry between operations possible.

Sorry to not elaborate on this point: perhaps someone will tell me my intuition here is wrong.

## Conclusion

So the asymmetry appears to be encapsulated by this description of an object as "a monoid in the category of blah." At that point, the operation of the underlying category gets a station different from that of the operation introduced by the monoid.