1
$\begingroup$

Could for example the precedence ordering of addition, multiplication, exponentiation, boolean and/or and zip/cross product be inferred from a few rules?

$\endgroup$
4
  • 2
    $\begingroup$ What makes you think so? My guess is you're going to be disappointed by the answer "arbitrary convention". $\endgroup$
    – Raphael
    Commented Oct 18, 2017 at 10:22
  • $\begingroup$ Why would there be a theory? People have been using, e.g., addition and multiplication for much longer than abstract algebra has existed. $\endgroup$ Commented Oct 18, 2017 at 10:38
  • $\begingroup$ Because polynomials can't be written without parentheses with infix operators and different precedence rules and I assumed that the addition of Boolean algebra and combination of lists might be generalizations of polynomials. $\endgroup$ Commented Oct 18, 2017 at 11:35
  • $\begingroup$ @rubystallion You assume that the "inventors" of the now "normal" operator precedences knew and cared about polynomials. $\endgroup$
    – Raphael
    Commented Oct 18, 2017 at 18:22

1 Answer 1

3
$\begingroup$

There is really no theory behind it: operator precedence is a purely human construct.

The reason is that expressions are not linear blocks of text. They are trees. For example, you can represent any arithmetic in Reverse Polish Notation. In a tree, there is no ambiguity. An operator acts on its children, end of story.

Humans are good at reading things linearly, and bad at reading trees hierarchically. So, we write equations and expressions as linear sequences of characters, with rules for parsing, parentheses to imply the tree structure, and operator precedence rules to remove some of the "obvious" parentheses.

One could imagine a system in which 2+3*4 was (2+3)*4. Math works just as well in such a system, and the choice is totally arbitrary. It is simply not the arbitrary choice we happen to use.

$\endgroup$
1
  • 1
    $\begingroup$ I think humans are Ok at reading trees hierarchically. They are bad at writing trees. Just try adding a tree representation of 2+3*4 to your post. $\endgroup$
    – gnasher729
    Commented Oct 18, 2017 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.