Operations and Closure
August 25, 20268 min readbeginner
A set on its own is just a collection. What makes a set interesting for arithmetic is that you can take two of its elements and combine them to get a third element.
A set on its own is just a collection. What makes a set interesting for arithmetic is that you can take two of its elements and combine them to get a third element. Combining two things to get one thing is called an operation. This note is about operations, the idea of "staying inside" the set, and why "staying inside" is the property we will care about most.
01.Adding two integers
The most familiar operation is addition. Take two integers, say and . Add them. You get . Both and are integers, and so is , the result.
Notice that addition on has a nice feature: no matter which two integers you start with, the answer is again an integer. Pick and : their sum is , an integer. Pick and : their sum is , an integer. There is no pair of integers whose sum is somehow not an integer. Once you are working inside , addition keeps you there.
The same goes for multiplication on : , , . Always an integer.
Now try subtraction on the natural numbers . Take and , both naturals. Subtract: . The answer is not in , because negative numbers are not natural numbers. Subtraction "leaks" out of .
Try division on the integers . Take and , both integers. Divide: . The answer is not an integer. Division leaks out of .
That little contrast (addition keeping you inside vs. subtraction leaking out of ) is the whole motivation for the word closure.
02.Binary operations, formally
A binary operation on a set is a rule that takes two elements of and returns one element of . The word "binary" means "takes two inputs". The word "operation" is just a fancy word for "rule".
Formally, a binary operation on is a function
that takes a pair with and produces a single output, written , that is also in .
The set , called the Cartesian product, is the set of all ordered pairs of elements of . So is the set of all pairs where both and are integers.
The crucial part of the definition is the codomain: the function is required to land in . If you put two elements of in, you get one element of out. Always.
Given that strict requirement, addition is a binary operation on , and so is multiplication. But subtraction is not a binary operation on , because does not land in . Subtraction would only qualify on a set that contained the negatives, like .
When an operation does land back in the set every time, we say the set is closed under that operation. Closure is the precise way to say "stays inside".
03.A worked check for closure
Let us verify, line by line, that addition is closed on .
The claim: for every and every , the value is in .
The cases break into four, depending on the signs:
- If and , then , and is a natural number, so it is an integer.
- If and , the sum is the integer obtained by counting down steps from . Either you stay non-negative or you cross zero into the negatives. Either way, the answer is in .
- If and , mirror of case 2.
- If and , then is more negative than either of them, and is in the negative integers, so in .
That covers all pairs, so addition is closed on . The same kind of case analysis works for multiplication.
For subtraction on , the counter-example is enough. To say "this operation is not closed on this set", you only need one counter-example. To say "this operation is closed", you have to handle every possible pair, which is what we just did for .
04.Why we care about closure
Closure is the property that lets you keep working without leaving the world you started in. If you are designing a piece of cryptographic hardware that handles 16-bit unsigned integers, you would like the operations you do (addition, multiplication, modular reduction) to stay inside the 16-bit range. If they leak out, you have a bug or you need a wider data type.
In the abstract language of this chapter, closure is the very first property a set needs in order to be a group, ring, or field. Those names come up in the next note. Each of them is a set together with one or two binary operations, and one of the first conditions every definition will demand is closure under those operations. Without closure, the rest of the structure cannot get off the ground.
05.Properties beyond closure
Closure is the floor, not the ceiling. Real arithmetic obeys a few more laws that you have known since elementary school but never named.
Associativity is the law that says it does not matter how you group the operands. For addition: . For multiplication: . Subtraction is not associative: , but . Two different answers.
Commutativity is the law that says the order of the two inputs does not matter. For addition: . For multiplication: . Subtraction is not commutative: .
An identity element for an operation is an element that does nothing when combined with anything else. For addition on , the identity is , because for every . For multiplication on , the identity is , because . Some operations have an identity and some do not.
An inverse of an element , with respect to an operation that has an identity , is an element that combines with to give . For addition, the inverse of is , because . For multiplication on (not on ), the inverse of (assuming ) is , because . The integer does not have a multiplicative inverse inside , since is not an integer, but does have an inverse in .
These four ideas (closure, associativity, commutativity, identities, inverses) show up again and again. They are the building blocks of the formal definitions in the next note.
06.A small exercise to check yourself
Consider the set with the operation defined as ordinary integer addition.
- Is closed under ? Compute . The result is not in . So is not closed under ordinary addition.
Now redefine on by the rule "take the ordinary sum, then keep only the last bit", so and and and .
- Is closed under this new ? Yes, every output is or .
- Is the new commutative? Yes, addition does not see the order.
- Is there an identity? Yes, for every .
- Does every element have an inverse? Yes, is its own inverse, and is its own inverse since .
What you have just constructed, by tweaking ordinary addition to stay inside , is the simplest non-trivial example of modular arithmetic. The trick of "take the result, then reduce modulo " is exactly what we are about to study in detail. Before that, the next note introduces the named structures (groups, rings, fields) that this modulo- system will turn out to be an example of.