HexGraphIsoTheory relates the executable coloured graphs to Mathlib's
SimpleGraph and extends the same graph_iso syntax to closed
ground SimpleGraph terms. The two families below are parametrised and
deliberately have different vertex types (Fin 2 × Fin p, a rim/spoke
coordinate, for the generalized Petersen graph, and the two-element
subsets of Fin 5 for the Kneser graph), so the positive goal genuinely
enumerates two unrelated finite types and returns a SimpleGraph.Iso,
rather than recognizing a definitional equality. graph_iso is a
decision procedure on closed ground instances, so the parameters must be
literals at the use site.
A finite simple graph with an ordered vertex colouring by Fink in
which every colour is used. This is the Mathlib-side counterpart of
Hex.GraphIso.Colored: the colouring need not be proper, and an
isomorphism has to preserve each colour index.
Two coloured Mathlib graphs are isomorphic exactly when their
encodings have equal canonical forms. The right-hand side is a decidable
equality of executable values, so this reduces a Mathlib isomorphism
question to running the canonical labelling.
For a Mathlib-side coloured graph G, its colour-preserving
automorphism group is the type
Colored.Iso G G. The theory companion
gives this type a Group instance and lets it act on the vertices. A
choice of enumeration e : V ≃ Fin n then identifies it, as a group,
with the subgroup of executable permutations that preserve the encoded
graph.
Encoding is an isomorphism of full automorphism groups.
The decoded list autos e G contains
colour-preserving self-isomorphisms. Its completeness theorem is stated
directly with Mathlib's Subgroup.closure: every
element of Colored.Iso G G belongs to the subgroup generated by that
list.
The automorphism generators found by Hex.GraphIso.Aut.gens on the
encoding, decoded as colour-preserving self-isomorphisms of the Mathlib
graph. Each entry is an automorphism, by Hex.GraphIso.Aut.gens_isIso
and isoOfIsIso. autos_complete proves that this list generates the
full automorphism group.
Every colour-preserving automorphism belongs to the subgroup generated
by the decoded list.
The reported orbit array also describes the action of the full group,
not merely the action of the generators encountered before a particular
point in the search. Equality of two stored representatives is
equivalent to the existence of a colour-preserving self-isomorphism
carrying one vertex to the other. The quotient equivalence exposes the
same fact in Mathlib's group-action vocabulary.
Encoding preserves the full automorphism orbit quotient.
Finally, the two numerical results have exact cardinality theorems.
autNumOrbits e G is the cardinality of the orbit quotient for the
action of Colored.Iso G G on V, and autOrder e G is the cardinality
of Colored.Iso G G itself.
The direct graph_iso extension on Mathlib graphs uses the dense
encoding. To select sparse nauty, apply
Sparse.encode_iso_iff
and then use graph_iso on the resulting native sparse goal. Both
enumerations may be chosen independently. The theorem transports the
answer back to the original coloured Mathlib graphs.
Here two presentations of a five-cycle use steps of one and two in
Fin 5. A path on the same five vertices supplies a negative example.
The definitions and claims are on the Mathlib side; the sparse
encoding appears only inside the proofs.
Sparse.encode constructs
sorted neighbour rows without allocating a dense matrix. Given only
an arbitrary decidable adjacency relation, it still tests vertex pairs.
For input already available as an edge list, the native
SparseGraph.ofEdges constructor avoids
that quadratic enumeration.
Sparse.iso_iff_canon_eq
characterizes Mathlib isomorphism by equality of the computed sparse
forms, and
Sparse.canon_encode_eq
proves independence from the chosen enumeration. A successful
isomorphism search can also be decoded directly with
Sparse.isoOfFindIso.
The automorphism operations have the same Mathlib interpretations as
their dense counterparts.
Sparse.autEquiv identifies
the colour-preserving Mathlib automorphism group with the executable
sparse permutation subgroup.
Sparse.autos_complete
states generation using Subgroup.closure, and
Sparse.autos_sameOrbit
identifies the computed representatives with the full group action.
The numerical results are exact cardinalities: