Chinese remainder theorem Created 2026-09-24 Updated 2026-10-20
The Chinese remainder theorem says that remainders modulo pairwise coprime positive integers can be specified independently. For pairwise coprime and , every prescribed list determines one congruence class modulo satisfying for all . It determines a class, rather than one unrestricted integer: adding a multiple of preserves every remainder.
For example, combine and . Write from the first condition. The second becomes . Since three has modular inverse two modulo five, , giving . The integers , and all work. The fifteen possibilities modulo fifteen correspond to the fifteen pairs in a three-by-five grid.
The theorem also preserves arithmetic: reducing an addition or a multiplication modulo each gives the same tuple as performing that operation on the corresponding congruence classes. In the language of quotient rings, reduction is a ring isomorphismOne large residue is thus an exact encoding of several smaller residues. This is useful for splitting arithmetic into smaller calculations and then reconstructing the result; MIT's modular arithmetic notes develop both the reconstruction and the product representation. [ref]
https://ocw.mit.edu/courses/18-200-principles-of-discrete-applied-mathematics-spring-2024/mit18_200_s24_lec15.pdf. Moitra, MIT 18.200, Lecture 15, section 4, Chinese remainder theorem
For a concrete multiplication, corresponds to and to modulo . Their componentwise product is , which reconstructs to , agreeing with .A constructive formula explains the independence. For , put and choose with , using a modular multiplicative inverse. Then is one modulo and zero modulo every other . Thereforehas the desired remainders. A modulus equal to one imposes no restriction and can be omitted. Uniqueness follows because a difference divisible by every is divisible by their product when they are pairwise coprime. This short construction gives a reusable algorithm as well as an existence statement.
The coprime hypothesis explains why every cell in the left grid is attainable. With integer moduli six and eight, a pair must agree modulo their greatest common divisor, two. There are twenty-four compatible pairs, rather than forty-eight arbitrary pairs; each corresponds to a class modulo the least common multiple, twenty-four. The Chinese remainder theorem for noncoprime moduli states the resulting compatibility rule.
Closure under a binary operation 2026-10-14
A subset is closed under a binary operation on when the result of combining any two elements of is again in . The even integers are closed under addition, but the odd integers are not: is even. Closure permits restricting the binary operation to . It is different from being a closed set in topology.
Common subexpression elimination 2026-10-31
A transformation that computes a repeated program expression once and reuses its saved result when the value is known not to have changed. A repeated load can be reused only when intervening stores, calls or other changes cannot alter the relevant location. Alias analysis helps establish that fact. Maximal address sharing can be counterproductive if instruction selection could otherwise fold an address addition into register-offset addressing.
Compilation arithmetic example 2026-10-14
Consider the program expression
x*(2+3)-4 in a deliberately small programming language. Its only program identifier is x, supplied as an integer input. Its literal values are nonnegative decimal numerals, interpreted as integers. Whitespace is ignored between lexical tokens. Its context-free grammar is:expression ::= term (("+" | "-") term)*
term ::= factor ("*" factor)*
factor ::= numeral | "x" | "(" expression ")"
numeral ::= digit digit*
digit ::= "0" | "1" | "2" | "3" | "4"
| "5" | "6" | "7" | "8" | "9"Here
* outside quotation marks means zero or more repetitions. Repeated operators are grouped to the left, specifying operator associativity; term gives multiplication higher operator precedence than addition and subtraction. Parentheses override that grouping. There is no unary minus, variable assignment, function call, or side effect in this language. Evaluation obtains each left operand before its right operand and uses exact integer arithmetic, with no fixed-width overflow.Lexical analysis recognizes
x, *, (, 2, +, 3, ), -, 4. Parsing constructs the concrete abstract syntax tree Sub(Mul(Name(x), Add(Int(2), Int(3))), Int(4)). Parentheses have done their work by making Add a child of Mul; they need not survive as nodes. Constant folding changes this to Sub(Mul(Name(x), Int(5)), Int(4)). It cannot replace Name(x) by a literal value because the input is supplied at execution. The resulting function of the input is .A compiler for our stack machine emits
LOAD x; PUSH 5; MUL; PUSH 4; SUB. LOAD x pushes the current input; PUSH n pushes the integer literal value n. Each binary instruction removes the top item as its right operand, then the next item as its left operand, and pushes the result. The instruction sequence is an intermediate representation that an interpreter can execute; no machine code has been emitted. A compact binary encoding could make it bytecode, but these printed instruction names are only a readable notation.Why does this compilation preserve the result? A structural induction supplies a short proof outline. Translating a literal value or
x appends its value to any initial stack. For a binary abstract syntax tree node, first translating the left child and then the right child appends the two operand values; the matching instruction replaces them by exactly the original operation's result. Previously present stack items remain intact. Constant folding also preserves the result because in the specified integer arithmetic. Together these facts explain agreement for every integer input, rather than merely agreement for one trial. Complex number Created 2026-09-24 Updated 2026-10-14
A complex number is , where are real numbers and the imaginary unit satisfies . The real part is and the imaginary part is : for they are and , respectively. Equality requires both coordinates to agree. Thus the complex plane gives each complex number a concrete position, while ordinary addition and multiplication become geometric operations.
For and , addition works coordinate by coordinate, whereas multiplication uses :These answers encode different motions: addition by is a translation, while multiplication by is a rotation combined with a uniform change of size. Keeping these pictures distinct prevents a common beginner's confusion.
The complex numbers form a field: every nonzero has a multiplicative inverse, computable using its complex conjugate and modulus. They also supply the missing solutions of a quadratic equation such as , namely . The surprising payoff is that extending arithmetic also makes Euclidean geometry easier to calculate. For a systematic introduction to these definitions, see Jeremy Orloff, MIT 18.04, topic 1, sections 1.3–1.5.
Congruence modulo an ideal 2026-10-14
Two elements of a commutative ring are congruent modulo an ideal if their difference lies in that ideal, equivalently if their images in the quotient ring agree. This is an equivalence relation compatible with addition and multiplication. For and , it means every coefficient difference is divisible by .
Constant folding 2026-10-13
Constant folding replaces a program expression whose value is known during translation by a literal value. For
x=2+3*4, first replace the multiplication subtree by Constant(value=12), then replace the addition subtree by Constant(value=14). The variable assignment and its Store target survive: the result still assigns to x. This illustrates why a bottom-up abstract syntax tree traversal is convenient: replacing one child can make its parent eligible for the next replacement.Here is a deliberately small Python transformer. Calling
generic_visit first transforms the children; returning a node replaces the visited node. The location helpers retain or supply the metadata expected for compilation. [ref]ast — Abstract syntax trees, Python 3.14 documentation. NodeTransformer, generic_visit, copy_location and fix_missing_locations
class FoldIntegers(ast.NodeTransformer):
def visit_BinOp(self, node):
self.generic_visit(node)
if (isinstance(node.left, ast.Constant)
and isinstance(node.right, ast.Constant)
and type(node.left.value) is int
and type(node.right.value) is int
and type(node.op) in OPS):
value = OPS[type(node.op)](node.left.value, node.right.value)
return ast.copy_location(ast.Constant(value=value), node)
return node
tree = ast.parse("x=2+3*4", optimize=0)
folded = ast.fix_missing_locations(FoldIntegers().visit(tree))
namespace = {}
exec(compile(folded, "<folded example>", "exec"), namespace)
assert namespace["x"] == 14
assert ast.unparse(folded) == "x = 14"This transformer folds literal integer operands only. It leaves
a+3*4 as a+12, without inventing a value for the program identifier a. It leaves calls intact: replacing 0*f() by 0 could discard a side effect or a failure. Nor does it reassociate floating-point arithmetic, where changing parentheses can change rounding. For the supported integer arithmetic, a short structural induction explains correctness: a retained literal value has the same value; at each folded binary node, the already-correct child values are combined by exactly the original operation in the original left/right order. This claim concerns the supported fragment's values, not unrestricted equivalence of arbitrary Python programs. Constant-time distinct-size counter 2026-10-25
Maintain a counter equal to the number of positive count-array entries. Increment it only when an addition changes zero to one; decrement it only when a removal changes one to zero. Other count changes leave the support unchanged. Initialization at zero and these cases prove the representation invariant by induction over completed operations, giving a constant-time distinct-size query.
Continuous function Created 2026-09-24 Updated 2026-10-14
A continuous function sends sufficiently nearby function inputs to nearby function outputs. For a real-valued function and a point that is an accumulation point of , this meansThe approached value and the assigned value must agree. Continuity on means continuity at every point of the domain of a function. At an endpoint of an interval, only approaches inside that domain of a function count. The epsilon-delta definition of continuity below also applies at an isolated point, where continuity holds automatically.[ref]
Calculus Volume 1, §2.4 Continuity. §2.4, Continuity at a Point: definition; Continuity over an Interval: one-sided endpoint conditions
For the polynomial function , approaching makes the function output approach . The continuity bounds for the square function turn this observation into an explicit guarantee: implies . This is useful whenever a small error in an function input must produce a controlled error in an function output. The required input tolerance can depend on the point and on the chosen output tolerance.
The absolute value function is also a continuous function, including at zero: . But its left and right derivatives there are and , so it is not a differentiable function at zero. Continuity controls values without requiring a tangent line. Conversely, a differentiable function is continuous wherever it is differentiable: if , the difference tends to zero with .
Several useful consequences reuse this one local idea. Addition, multiplication and function composition preserve continuity; a quotient of functions is continuous where its denominator is nonzero. On an interval, the intermediate value theorem turns continuity into a guarantee that no intermediate function output is skipped. On a compact set, the extreme value theorem guarantees attained maximum and minimum values. Those extra hypotheses matter: continuity alone on an unbounded domain of a function does not provide a global bound or an attained global maximum.
A rational function such as is continuous on its domain of a function . Zero is excluded from that domain of a function; the missing point prevents a continuous extension there, but it does not make the existing map discontinuous at one of its actual inputs. Always state the domain of a function before judging continuity.
For a deterministic binary operation on an abstract data type, let be its specified operation on abstract values and the implementation on concrete states. For every permitted valid input pair , require bothThe first condition preserves the representation invariant. The second makes a commutative diagram: either execute and then apply the abstraction function, or apply the abstraction function to both inputs and then execute the abstract operation ; both paths reach the same value. These conditions state functional correctness of a completed operation; termination is an additional obligation for algorithm correctness.[ref]
8.3 Module Documentation. Sections 8.3.3, Commutative Diagrams, and 8.3.4, Representation Invariants: matching abstract results and preservation of valid representations
For addition in the unreduced rational representation, chooseFor example, represents , precisely the sum of and . The short correctness argument uses nonzero denominators: and imply , preserving the representation invariant, and
Correct rational addition makes both paths agree; an invariant-preserving incorrect operation gives a different value
. Details. Now consider an incorrect implementation that uses addition on the numerators and multiplication on the denominators:It preserves the representation invariant for every valid input pair because its denominator is still . Yet represents , not the specified sum . Even perfect checks of the representation invariant before and after this call would miss the error: the result is a legal representation of the wrong rational number.
The incorrect operation also exposes an accidental dependence on representation. Replace by the equivalent state while keeping . The correct operation gives , still representing ; the incorrect operation gives , representing instead of its previous . A correct addition must yield the same abstract result for equivalent inputs, although its concrete outputs may differ. This is why checks against the formal specification should compare abstract values, including unreduced representations and representations with a negative denominator, rather than demand identical stored pairs.
The calculation assumes exact integers. An implementation with bounded storage must additionally specify how it handles products and sums outside its supported range; the mathematical argument alone does not establish its functional correctness. The bounded queue with encapsulation illustrates the corresponding need to account for returned status values and failed operations, alongside the abstract state transition.
Cyclic group Created 2026-09-24 Updated 2026-10-14
A cyclic group is a group that can be generated by repeating a single group element and its inverse element:For an additive group, the same expression is written : means repeated addition, including subtraction when is negative. A finite cyclic group has a repeating cycle, while an infinite cyclic group is isomorphic to the additive integers. The notation refers to a finite cyclic group of order .
This definition compresses a whole composition rule into one repeatable operation. Once is chosen, , so working with group elements becomes working with integer exponents. In the finite case those exponents are reduced using modular arithmetic. It also proves that every cyclic group is an abelian group, because . A finite cyclic group of order has exactly solutions of for every positive integer divisor of : in exponents, has exactly solutions modulo . The standard finite and infinite models are described in Group Theory (v4.01) by James S. Milne (section 1.16).
Cyclic group of order four and Klein four-group Created 2026-10-14 Updated 2026-10-31
The finite cyclic group and the Klein four-group are both abelian groups of order four. In , composition is addition modulo four. In , label the elements and add each coordinate modulo two. For example, and .
Two abelian groups of order four have different addition tables
. Each cell is the row element plus the column element. Diagonal cells record adding an element to itself. In , only and return to zero after two additions. In the Klein four-group, every diagonal cell is the identity element . The symmetric tables show commutativity, while the different doubling behavior distinguishes the groups. Details.The order of a group element is preserved by a group isomorphism: an equation holds exactly when its image satisfies the same equation. In , both and have order four. In , each nonidentity element has order two. Hence these groups are not isomorphic, despite having the same order of a finite group. No relabelling can repair this discrepancy.
For a geometric model of , take the symmetries of a non-square rectangle: the identity element, reflection in its horizontal axis, reflection in its vertical axis, and rotation through . The two reflections commute, and their composite is the half-turn. Every nonidentity motion is its own inverse element. This makes the two binary switches concrete: choosing whether to apply each reflection specifies all four motions. The case of abelian groups of prime-square order generalizes this distinction from to any prime .
Degree of a polynomial Created 2026-09-24 Updated 2026-10-25
The degree of a nonzero polynomial is the largest exponent of a monomial with a nonzero coefficient. Thus has degree three, while any nonzero constant polynomial has degree zero. The zero polynomial is treated separately in degree statements.
Over an integral domain, polynomial degrees add under multiplication: for nonzero factors, because the product of their leading coefficients cannot vanish. Under addition, cancellation may lower the degree: . This explains why degree is reliable for counting factors and bounding polynomial roots, but cannot always be inferred from the degrees of summands alone.
Discontinuous additive function 2026-10-18
Assuming the axiom of choice, Cauchy's functional equation has solutions that are not linear maps over the real numbers. Regard as a vector space over the rational numbers. Because is an irrational number, and are linearly independent over . Zorn's lemma extends them to a Hamel basis ; assigning arbitrary real outputs to its basis vectors and extending by finite rational linear combinations gives an additive function.[ref]
Zorn’s Lemma and Some Applications by Keith Conrad. §4, printed pp. 19–20, Corollaries 4.2 and 4.5: basis extension and an additive map not of the form cx
For a particular choice, assign and for every . Every real number has a unique finite linear combination with finite and . Definewhere the coefficient is zero if . The uniqueness of the Hamel basis representation makes this definition unambiguous, and adding the coefficients proves . On the rational two-dimensional vector subspace spanned by and , the rule is particularly simple:For instance, and give , , and . Thus the map still preserves addition, even though rules out being a linear map over the real numbers.
The rational approximants from additive function continuous at one point is linear expose the failure of continuity: but . Moreover while . The map is continuous nowhere, since continuity at any point would imply additive function continuous at one point is linear. It is unbounded on every interval of positive length by additive function bounded on an interval is linear.
The axiom of choice is used to obtain the Hamel basis; the coefficient rule does not provide an explicit way to find the representation of an arbitrary real number. A plot sampled only at rational numbers would show exactly the same values as , so that plot cannot reveal this discontinuous additive function.
Divide-and-conquer product ledger 2026-10-18
Splitting two integers in positional notation gives and , where shifts a block by numeral digits in fixed radix . The distributive property givesComputing separately needs four block multiplications. Merely halving the operands therefore gives an ideal recurrence relation , still with quadratic time complexity. The Karatsuba three-product identity instead computes , and , recovering the middle coefficient by two subtractions. The MIT notes present precisely this four-product versus three-product distinction.[ref]
Lecture 11: Numerics I. 6.006 Introduction to Algorithms, Fall 2011, Lecture 11: Numerics I, printed pp. 4–5, High Precision Multiplication and Karatsuba's Method
For an original small example, multiply by . Set , , , , . Four separate block products would give , , , . The three-product calculation isThe crucial reuse is that and supply the outer coefficients and also remove the unwanted terms from . There is no need to compute and separately. Expanding proves the identity. Induction extends it to Karatsuba multiplication once each smaller block product is correct and Karatsuba recursion termination supplies decreasing sizes and complete base cases.
Four block products or three: the exact ledger for
. The left ledger computes both cross products separately. The right ledger reuses and to recover their sum as . Both reconstructions yield . Counts refer to block multiplication calls at this split; the extra numeral digit in prevents interpreting all three as single-digit products. Details.The operation model matters. Let count numeral digits in fixed radix , and count single-digit multiplication, addition, subtraction and copying as constant-cost operations. The nonrecursive work on size- operands is : it includes forming sums, positional shifts and Karatsuba carry handling. Treating an arbitrarily large integer multiplication as one operation would hide the very saving being studied. The coefficients above must be shifted and added; concatenating them does not give .
In the ideal equal-half model, Karatsuba multiplication has . At depth its additional work is at most a constant times , and its leaf count is for . A geometric series gives , where . Four recursive products would instead give leaves. Saving one block product repeatedly changes the exponent, even though the combination requires extra addition and subtraction.
For the literal sum-based version, each operand sum can occupy one extra numeral digit. Its worst-case upper recurrence relation is for a nondecreasing cost envelope, above a fixed base case threshold of at least three digits. Karatsuba digit-operation cost proves that this extra digit preserves the exponent; Karatsuba operand splitting handles odd lengths and leading zero padding. For signed integers, apply the nonnegative procedure to their absolute values and restore the sign. The small ledger establishes an exact identity, while Karatsuba practical crossover explains why it alone cannot predict a speedup for two-digit operands.
Empty sum 2026-10-14
An empty sum has no terms and is defined to be zero, the identity element for addition. This keeps the rule for combining sums valid when one index set is empty. In a Galton-Watson process, an empty generation contributes an empty sum of offspring counts, so the next generation is empty too. The corresponding convention for multiplication is the empty product, which equals one.
Endomorphism Created 2026-09-24 Updated 2026-10-14
An endomorphism is a morphism : its source and target are the same object, with the same specified structure. For a group it is an operation-preserving group homomorphism back into that group; for a vector space it is a linear endomorphism; for a ring it is a ring endomorphism. A self-map must satisfy the chosen compatibility conditions to qualify. The notation records the category in which these conditions are imposed. See Riehl, Category Theory in Context, Definition 1.1.10 and the following paragraph.
An endomorphism can lose information or miss part of its target. On the additive integers, preserves addition and is injective, but is not surjective: no integer maps to . On the vector space over the real numbers, the linear endomorphism loses the second coordinate, so it is neither injective nor surjective. Neither is an automorphism. The same doubling rule becomes a group isomorphism when its target is the additive even integers, as explained under isomorphism.
The finite cyclic group offers a small example of information loss that can be drawn completely. With addition in modular arithmetic, the endomorphism sends the inputs to . Its image of a group homomorphism is and its kernel of a group homomorphism is . Each reached output has two inputs; the other three outputs are missed.
For an endomorphism of a group or ring with a finite underlying set, injectivity is equivalent to surjectivity by counting; either condition makes it an automorphism. The additive integers example shows why the finiteness assumption matters. A linear endomorphism of a finite-dimensional vector space also has equivalent injectivity and surjectivity, this time by the rank-nullity theorem even when its underlying set is infinite.
Self-maps can be iterated without changing the object: , , and so on. Composition in a category and the identity morphism make the endomorphisms of a fixed object in a locally small category into a monoid. This packages repeated compatible operations, including irreversible ones, into a single structure.
The general language has a documented historical milestone in the 1945 paper of Samuel Eilenberg and Saunders Mac Lane. They defined categories of objects and compatible maps, and distinguished maps admitting inverses within that category. Their examples included groups, vector spaces, and topological spaces. This gave a common framework for compatible self-maps and their invertible cases. See Eilenberg and Mac Lane, General Theory of Natural Equivalences, pp. 234 and 237–239.
Endomorphism of a finite cyclic group 2026-10-14
Every endomorphism of the additive finite cyclic group , for a positive integer , has the form , determined by . This is the self-map case of homomorphism from a finite cyclic group: repeated addition forces the value at every element. Conversely, each choice of respects addition and gives a well-defined map on congruence classes.
Let , the greatest common divisor. The image of a group homomorphism is the cyclic subgroup generated by , with size by order of an element of a finite cyclic group. The kernel of a group homomorphism isIndeed, is equivalent to dividing , after cancelling and using coprimality. Consequently is a group automorphism exactly when and are coprime. In that case a modular inverse of gives . This connects reversible self-maps directly to the generators of a finite cyclic group.[ref]
Exclusive or Created 2026-09-28 Updated 2026-10-20
Exclusive or returns one exactly when its two input bits differ. Its truth table gives , , , and . The identitiesexpress exclusive or using logical conjunction, logical disjunction, and logical negation. The first expression accepts at least one input and then excludes both; the second explicitly lists the two accepted input pairs.
For numerical bits, exclusive or is addition in modular arithmetic modulo two:The binary operation is commutative and associative, because addition modulo two has those properties. It satisfies , , and . These identities explain why a bit can be toggled and restored with the same operation.
On binary strings of equal length, bitwise exclusive or applies the one-bit rule separately at each position. For example,A bit mask of toggles exactly the middle two bits. Applying the mask twice restores the original binary string: each selected bit changes twice, and each unselected bit stays fixed. This positional operation is distinct from taking the exclusive or of the overall truth values of two integers.
Field with four elements Created 2026-10-06 Updated 2026-10-14
Build this finite field by taking a quotient ring of a polynomial ring:The polynomial has in the prime field . A polynomial of polynomial degree two is an irreducible polynomial exactly when it has no polynomial root in the coefficient field. Thus the quotient by an irreducible polynomial is a field construction applies. Its elements have unique representatives , with : precisely .
The defining relation is . Since this finite field has characteristic two, every element equals its additive inverse, and the relation becomes . Addition acts separately on the two coefficients:All coefficient calculations use modular arithmetic modulo two. For example, and . Encoding as the pair of bits gives , , , and ; addition is bitwise exclusive or. These are coordinates in the basis , so the label does not make the element .
For multiplication, expand using the distributive property and replace every by :For example, , while . The following complete tables are computed from the coefficient rules. Colors identify results, rather than their numerical sizes. Every row of the addition table lists all four elements, and every nonzero row of the multiplication table does too: adding an element, or multiplying by a nonzero element, can be undone.
The nonzero multiplicative inverses are , , and . Consequently the equation has the unique solution . Repeated multiplication gives , , , and . They cycle through every element of the multiplicative group of a finite field.
Compare the ring , also with four elements. Its addition satisfies , and its multiplication satisfies . Thus is a zero divisor, with no multiplicative inverse, and this ring is not a field. Multiplying by collapses different inputs to the same output: both and give , while both and give . In the field with four elements, multiplying by instead rotates the three nonzero elements, preserving their distinctness. The figure makes visible why counting four elements alone does not specify their arithmetic.







