All Tutorials Tutorial

Geometry, Combinatorics, Codes & Cryptography

Handbook survey

Magma's handbook devotes dozens of chapters to areas outside pure algebra: discrete geometry, combinatorics, graph theory, coding theory, cryptographic building blocks, and optimization. This lesson is a bird's-eye survey rather than a deep dive — the goal is a mental map of what each area covers and which Magma category you would reach for, not full command coverage. Treat it as a directory: when a project needs one of these tools, come back and look up the relevant chapter.

Topology: Simplicial Complexes

The SmpCpx category models finite abstract simplicial complexes — a set of "faces" (subsets of a vertex set) closed under taking subsets. This is the combinatorial skeleton used for computing simplicial homology. Complexes are usually built from a list of maximal faces.

> K := SimplicialComplex([{1,2,3}, {2,3,4}, {4,5}]);

Most of the constructive machinery expects faces to be sets of integers (a "normalized" complex), with renumbering utilities available for complexes over arbitrary vertex sets.

Geometry: Planes, Incidence Geometries, Polyhedra

Three chapters cover geometric structures at different levels of abstraction. PlaneProj and PlaneAff are the categories for finite projective and affine planes; "classical" planes among these come from a vector space of dimension 3 (projective) or 2 (affine). Points and lines get their own special types (PlanePt, PlaneLn) with dedicated point-sets and line-sets as parent structures.

Incidence geometries generalize this idea: a geometry is a tuple of elements, a type function, and a symmetric incidence relation, following the Tits/Buekenhout framework. Magma can also build large incidence geometries cheaply from a group and a family of subgroups — the resulting coset geometries use the group's cosets as elements and subgroup intersection as incidence.

Polyhedra live in a separate, more numerical world: the Polyhedra package builds rational polytopes and cones inside a lattice $\mathbb{Z}^n \subset \mathbb{Q}^n$, supporting Minkowski sums, vertex/face enumeration, and triangulation.

> P := Polytope([[0,0],[1,0],[0,1]]);

Combinatorics: Counting, Tableaux, Symmetric Functions, Designs, Hadamard Matrices

Several chapters together form Magma's combinatorics toolkit. EnumComb supplies basic enumerative building blocks — factorials, permutation and combination counts, and similar counting functions. The Tableau chapter builds on this with integer partitions, words, and Young tableaux, which are foundational for representation theory of the symmetric group. AlgSym then uses partitions to index the five classical bases (Schur, homogeneous, power sum, elementary, monomial) of the algebra of symmetric functions.

> Partitions(5);
[ [5], [4,1], [3,2], [3,1,1], [2,2,1], [2,1,1,1], [1,1,1,1,1] ]

Combinatorial designs form their own strand: an incidence structure Inc is a triple of points, blocks, and a flag relation, and a design adds balance conditions (every $t$-subset of points lies in the same number $\lambda$ of blocks). Hadamard matrices are a related but separate topic — $\pm1$ matrices with pairwise-orthogonal rows/columns — with Magma offering canonical-form-based equivalence testing built on nauty/Traces.

Graphs, multigraphs, and networks round out combinatorics. Plain graphs (GrphUnd, GrphDir) forbid loops and parallel edges; multigraphs (GrphMultUnd, GrphMultDir) allow both; a network (GrphNet) is simply a multidigraph whose edges always carry a capacity, used for flow, shortest-path, and matching problems.

> G := Graph<5 | {1,2},{2,3},{3,4},{4,5},{5,1}>;

Coding Theory: Fields, Rings, Z4, Additive and Quantum Codes

Coding theory gets the largest cluster of chapters here, organized by the alphabet a code lives over. CodeFld is the base case: a linear $[n,k,d]$ code over a finite field $GF(q)$, defined as a $k$-dimensional subspace of $n$-tuples measured with Hamming distance. CodeRng generalizes this to codes over finite rings (integer residue rings, Galois rings), where the lack of free modules forces a pseudo-dimension (via Howell form) in place of ordinary dimension. CodeZ4 specializes further to codes over $\mathbb{Z}_4$ ("quaternary" codes), with dedicated machinery for Lee weight, the Gray map to binary codes, and families like Hadamard/perfect $\mathbb{Z}_4$-codes.

CodeAlG (algebraic-geometric codes) constructs Goppa-style codes from divisors on an algebraic curve — a bridge between coding theory and algebraic geometry. CodeLDPC covers low-density parity-check codes, built from sparse (regular or irregular) parity-check matrices and typically studied by simulation rather than explicit construction. CodeAdd introduces additive codes, a $K$-linear (rather than $F$-linear) subspace of $F^n$ for a subfield $K \subseteq F$, allowing fractional dimensions; these are the foundation for QECC, Magma's quantum error-correcting code package, motivated by the need to correct errors on qubit states without violating the no-cloning theorem.

> C := LinearCode<GF(2), 7 | [1,0,0,0,1,1,0], [0,1,0,1,0,1,0], [0,0,1,1,1,0,1]>;
> MinimumDistance(C);

Cryptography: Pseudo-Random Sequences

The PseudoRandom chapter is narrowly scoped: tools for generating and analyzing pseudo-random bit sequences, mostly over $GF(2)$. Its centerpiece is the linear feedback shift register (LFSR) — a sequence generator driven by a connection polynomial — together with analysis tools such as the Berlekamp–Massey algorithm, which recovers the shortest LFSR (and hence linear complexity) generating a given sequence.

> S := LFSRSequence(C, [1,0,1,1], 20);

Optimization: Linear Programming

The LP chapter handles linear programs: maximizing or minimizing a linear objective subject to linear constraints (equalities or inequalities) with implicit non-negativity on the variables. Magma offers two interfaces — direct solver functions over constraint matrices, or an LP process object where constraints are added incrementally before calling Solution. Problems can be posed over the integers, rationals, or reals, and are solved underneath by the lp_solve library, which reports back a status code (optimal, infeasible, unbounded, or failure) alongside the solution vector.

Where to Go Next

This tour deliberately skims the surface — each chapter above has its own much deeper handbook coverage (constructors, invariants, algorithms) that a focused lesson would walk through intrinsic by intrinsic. Use this map to recognize which chapter is relevant to a problem — a design vs. a graph vs. a code vs. an LP — before diving into its details.

Quiz