Closure of a Set Under an Operation
A set is closed under an operation when applying it to allowed operands always returns an element of that set.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Check two operations
Nonnegative integers are closed under addition. For subtraction, choosing two minus seven produces minus five outside the set. A proof by cases or a counterexample can justify the distinction.
Choose a valid retained domain
A loop subtracting a requested amount from stock must ensure the amount is no greater than the current stock to preserve nonnegativity. Express that invariant in the update contract and test an amount exactly equal to stock.[1]
Prove closure for arbitrary allowed operands
The even integers are closed under addition because writing two inputs as \(2a\) and \(2b\) gives sum \(2(a+b)\). Integer division by two need not preserve the set, as two becomes one. Closure depends on the set and the chosen operation. See functions as discrete mappings.
Example closed operation: 6+8=14 stays even
Witness against halving: 2÷2=1 leaves the set
General sum argument uses arbitrary integers a and b
Separate closure from properties such as having an identity
The positive integers are closed under addition without containing the additive identity zero. An operation may also be undefined for some pairs, as division by zero is. State the allowed operand and output domains before applying the test.