Operator Laws
Operator Laws
What am I even talking about?
Before, we explored very naively what any operator is. For example, we decided to count up a specific number of times, and called it "addition", using the symbol "+". I've referred to expressions such as "3+4" as "7", reducing the terms by computing them. What does it all mean?
First of all, we mistakenly equated numerals like "32" or "6" as the "words" of math. It would be more correct to say these are nouns, and that symbols like "+", "-","*","/" are verbs. Even in English, when we say "Add three and four", the numbers "3" and "4" are the objects of the phrase, combined in such a way defined by the verb "add".
Just like reading a sentence is a complex procedure, so is parsing a mathematical expression. (This doubles as a very lightweight introduction to abstract syntax trees)
If we were to parse the famous sentence "The quick brown fox jumps over the lazy dog", we would end up with this following "concept graph".
Similarly, math expressions also have their own parsing rules. Important to note:
Expressions are always read and parsed left to right.
Different operators can have different priorities.
Each numeral counts as a term, while the symbols are operators.
Operators with a certain priority always "vacuum up" all other terms until encountering a symbol with the same or lower priority.
Parentheses have the highest priority (but are a bit special), followed by the symbols of "*" and "/" at the same level, followed by "+" and "-", with the lowest possible operator being "=" (yes, it's an operator).
For parentheses, it's best to think of them as "everything inside becomes a single term". This term cannot be split up easily, but it's sometimes possible (using the laws!).
As an example:
Let's think like a computer, and we'll build the graph as it goes.
Let's follow rule 1, and start reading from left to right.
We find a 5, this must be a first term for something.
We then find a "+". Clearly there has to be now a second term.
We now have to "vacuum up" all the terms until we find an operator with the same or lower priority.
We find a 9. We add it to our term.
We find a "*". It is higher priority than us, so we add it to the term.
We find a "7". We still add it to the term.
We find a "/". Still higher, so we add it to the term again.
We find a "3". Just a numeral again, so we add it.
We find a "-". This finally has our own priority, so we know that our vacuuming up in the second term has finished. The term we made, we do not yet explore. The "-" we found means that the result of our current operation (the "+"), is the first term of that other symbol.
We now check in with the continuation from "-". As per rule 4, we need to vacuum up all terms we see with our priority or higher.
We find a 4. Add it to the second term.
We find an "=". This is even lower priority than us, so we know to stop here, take our entire term as the "first argument" to the "=". Since we're an equal, we're also vacuuming up the rest of the terms until we find another "=" or we reach the end of the expression.
We can now expand the nodes that contain more complex operations. The procedure is exactly the same, except for the parentheses. By rule 6, we take 3+7 as a singular term, even if the "+" would have been lower precedence than the "*" preceding. Expanding everything we get:
We now go from the bottom operators, where we know we have all terms in proper numbers, and replace them with the result of the operation. (That means 9*7, and 3+7).
We repeat it, again.
We repeat it, again.
And again.
Until we remain with just "22=22", which technically is still an operator, which reduces to "True". And that's the final result of the equation.
And that's it! That's how a machine reduces the whole equation, in a very syntactical, foolproof manner. Humans instead can use shortcuts. Rather than building the whole tree, we can tell immediately "9*7/3" is possible to reduce, so we already substitute "21" to that term. Then we do both addition and subtraction to leave us with "22". Much easier to remember just that, rather than the whole tree! And in the opposite, since we know parentheses have the highest priority, we just solve the parentheses term, which becomes "10". "10*2" is then our new subterm, (since the +2 after has a lower priority), which we resolve to 20, finally adding up to 22.
Then we finally realize 22=22, and know the equation was correct all along. While this method seems a bit "overcomplicating" the situation, the reality of it is that parsing mathematical expressions was always that complicated, and the complexity is just "hidden" away by "internalizing the mechanics" of the operators. The "PEMDAS (parentheses, exponents (not yet shown here), multiplication, division, addition, subtraction)" acronym completely fails, because "multiplication" and "division" are at the same level of priority, and should be disambiguated only by reading it left to right.
For example:
If we subscribe to "PEMDAS" blindly, we see a "*" first and try to reduce it.
Therefore the result is 1... right? Sadly, since multiplication and division in reality have the same priority, we should bracket as we read left to right instead.
The correct result here is 4.
The same exact structure and failure also is present in the "addition" and "subtraction".
Subscribing blindly to "PEMDAS" makes the addition always first so:
But the correct reading is to parse it left to right, as they have the same priority:
If anything, there's an interesting structure coming from both of these. What if we instead used the "negative/inverse" element?
or in case of multiplication
Do not yet worry about the "1/4", as we usually defined it as "???", but we'll slowly expand what our concept of numbers is. Consider it the "antithesis" of a 4, in the same way that "-4" is our "negative particle" of 4.
The important thing here is that, we see the expressions for what they really are, a chain of "+" and a chain of "*". And now we ask ourselves... is ?
Since we're completely new to math, we cannot actually assume that swapping the terms around in any symbol will yield the same result. If anything we now know from both examples that the "-" and "/" symbol have trouble swapping numbers around. And we need structure, we need order, we need... operator laws!
(By the way, when I mentioned briefly the terms computing and reducing, the two are essentially the same thing. The act of taking an expression and slowly simplifying the terms, again and again. Computing "3+4" in order to arrive at "7" is the same as "reducing" the expression to simplest terms. What if an expression is on the form "x+4"? Can we even reduce it? We really don't know what "x" is so, assigning any random number is out of the question....)
Operator Laws
Ergo, how do I manipulate all these expressions???
Let's begin by being more abstract first. We're going to define a "placeholder" operator, using the symbol .
Law of Commutativity
This allows us to swap the terms around. This means also that "big terms" defined by operator precedence are also affected, that is, we move the entire term, not necessarily changing what's inside.
Law of Associativity
The last part of the equation is to show that if the two formulations are equal then we don't need parentheses anymore to disambiguate, it ends up being the same thing no matter which operation we do first.
Identity Element
Sneakily introducing more notation. The symbol is the "exists" logical operator, representing the concept of "exists (at least one)". It takes a number of variables in input (written after the symbol), and saying there's a combination of those variables values that makes the rest of the formula (after the variables, still within the context of the symbol, that is within parentheses/statement). In this case this is our (also called identity element).
The other logical operator is called "for all". It works the same as the "exists" operator but rather than a single value in the universe needed to satisfy the formula, it needs to work for all of them.
The above formula then reads: "Exists an element 'e' that for every element 'x', doing the operation, in any order, does not change the element 'x' from its value'. If you're still confused, it is very similar to saying, "there's an ingredient that makes every other food sweeter". The element could be "sugar" or "sweetener", but as long as one exists that works on every food, the statement is true.
(Small interjection for the advanced, and a preview of further delving: logic that only deals with the truth of selected statements is called "prepositional logic". Adding quantifiers (exists/forall) to this logic makes it "first-order logic". If this seems a bit more complicated, it's because it is, and I am not trying to hide where the complexity lies, but rather tackle it head on.)
Property of zero (a bit of a spoilery name)
Very similar to the previous formula, but still a little different. For the possibly confused, here I am trying to describe all the possible (and common) properties of an operator. I am not describing a specific one, but rather showing a variety of them, in order to identify the ones that apply to the operators we know.
Unlike the previous, that seemed to leave the element intact, this "e" seems to collapse everything on itself.
Distributive property
This one puts in relation two different operators, so here we introduce a operator to make do (think of it as a secondary placeholder, to signify the operators are different).
This allows us to either distribute the operation to both elements of the operation, or we can do the inverse, grouping up the part instead.
This is very powerful for manipulating expressions that otherwise would not be easy to simplify. In case of only numbers, it is not a big deal, but when thinking with variables mixed in, not using the property could get you stuck, while further simplification could have been achieved.
Inverse operation
Operator has an inverse operation .
This shows how two operations are linked together by being inverse of each other. This property might not fully hold if considering limited sets. A notation clarification here, means "if and only if". not only means, when A is True then B is True, but it also means the "contrapositive", that is "when B is True then A is True". That means that when one statement is True or False, the other must match.
F | F | T |
F | T | F |
T | F | F |
T | T | T |
Some clarifications
When speaking of "x", "y", "e", and the logical quantifiers, there's two fundamental assumptions here to be made. The formulas that do not show quantifiers implicitly have a "forall" quantifier for each variable that appears into the formula. Usually it is more explicit, but this being properties, the equation itself is the most important part.
Second, these quantifiers are usually enumerating the values present in an universe. If we were in the universe of fruits, , could only mean that "x" could take the values of "apple, banana....", but not "zucchini". To avoid ambiguity, usually, both the "forall" and "exists" quantifier have their variable take values from a set. Therefore, we can say that all the previous formulas could have been .