# Metamath Proof Explorer

An "extensible structure" (or "structure" in short, at least in this section) is used to define a specific group, ring, poset, and so on. An extensible structure can contain many components. For example, a group will have at least two components (base set and operation), although it can be further specialized by adding other components such as a multiplicative operation for rings (and still remain a group per our definition). Thus, every ring is also a group. This extensible structure approach allows theorems from more general structures (such as groups) to be reused for more specialized structures (such as rings) without having to reprove anything. Structures are common in mathematics, but in informal (natural language) proofs the details are assumed in ways that we must make explicit.

An extensible structure is implemented as a function (a set of ordered pairs) on a finite (and not necessarily sequential) subset of . The function's argument is the index of a structure component (such as for the base set of a group), and its value is the component (such as the base set). By convention, we normally avoid direct reference to the hard-coded numeric index and instead use structure component extractors such as ndxid and strfv. Using extractors makes it easier to change numeric indices and also makes the components' purpose clearer. For example, as noted in ndxid, we can refer to a specific poset with base set and order relation using the extensible structure rather than .

There are many other possible ways to handle structures. We chose this extensible structure approach because this approach (1) results in simpler notation than other approaches we are aware of, and (2) is easier to do proofs with. We cannot use an approach that uses "hidden" arguments; Metamath does not support hidden arguments, and in any case we want nothing hidden. It would be possible to use a categorical approach (e.g., something vaguely similar to Lean's mathlib). However, instances (the chain of proofs that an is a via a bunch of forgetful functors) can cause serious performance problems for automated tooling, and the resulting proofs would be painful to look at directly (in the case of Lean, they are long past the level where people would find it acceptable to look at them directly). Metamath is working under much stricter conditions than this, and it has still managed to achieve about the same level of flexibility through this "extensible structure" approach.

To create a substructure of a given extensible structure, you can simply use the multifunction restriction operator for extensible structures as defined in df-ress. This can be used to turn statements about rings into statements about subrings, modules into submodules, etc. This definition knows nothing about individual structures and merely truncates the set while leaving operators alone. Individual kinds of structures will need to handle this behavior by ignoring operators' values outside the range (like ), defining a function using the base set and applying that (like ), or explicitly truncating the slot before use (like ). For example, the unital ring of integers is defined in df-zring as simply . This can be similarly done for all other subsets of , which has all the structure we can show applies to it, and this all comes "for free". Should we come up with some new structure in the future that we wish to inherit, then we change the definition of , reprove all the slot extraction theorems, add a new one, and that's it. None of the other downstream theorems have to change.

Note that the construct of df-prds addresses a different situation. It is not possible to have SubGroup and SubRing be the same thing because they produce different outputs on the same input. The subgroups of an extensible structure treated as a group are not the same as the subrings of that same structure. With df-prds it can actually reasonably perform the task, that is, being the product group given a family of groups, while also being the product ring given a family of rings. There is no contradiction here because the group part of a product ring is a product group.

There is also a general theory of "substructure algebras", in the form of df-mre and df-acs. SubGroup is a Moore collection, as is SubRing, SubRng and many other substructure collections. But it is not useful for picking out a particular collection of interest; SubRing and SubGroup still need to be defined and they are distinct --- nothing is going to select these definitions for us.

Extensible structures only work well when they represent concrete categories, where there is a "base set", morphisms are functions, and subobjects are subsets with induced operations. In short, they primarily work well for "sets with (some) extra structure". Extensible structures may not suffice for more complicated situations. For example, in manifolds, would not work. That said, extensible structures are sufficient for many of the structures that set.mm currently considers, and offer a good compromise for a goal-oriented formalization.