Canonical branch pruning for the cubic matrix replay #
Certificate/CubicMatrixExhaustive.lean removed the generated tree, leaving
the leaf payloads as the whole remaining cost. This module supplies the
machinery to cut those down, and to cut the traversal down with them.
Everything here is generic in the vertex count and the degree. That is
deliberate: the genus-four instance at n = 6 is a proof of concept for the
genus-five instance at n = 8, where the numbers are
connected leaves + cut 0 + cut 0 and cut 1
n = 6 640 46 20
n = 8 168,840 4,470 777
The two cuts #
A node's state is really (S, residual capacity on V \ S) with S the set of
processed vertices; the row-by-row scheme is the special case where S is a
prefix. The freedom to choose which vertex to process next is exactly the
freedom to sort by relabeling, and that gives two cuts:
- cut 0 — relabel
1 … n-1so that row0is ascending; - cut 1 — then, within each maximal block of positions sharing a row-
0value, relabel so that row1is ascending. Such a permutation moves vertices only inside row-0level sets, so it preserves cut 0.
Both are witnessed by explicit permutations, so no canonical labeling happens inside Lean.
Ascending is deliberate and is worth about 25 per cent over descending: cut 1
does not move position 1, and ascending puts the smallest row-0 value
there, leaving larger blocks for cut 1 to act on.
What is here and what is not #
canonicalPrefix is the decidable predicate, prunedCheck is the traversal
that skips non-canonical branches, and prunedCheck_sound is its soundness.
Because the predicate only inspects rows 0 and 1, it is decided as soon as
those are chosen, so the pruning happens at the top of the tree where it saves
the most.
The remaining obligation is named CanonicalRepresentative: every candidate is
isomorphic to a canonical one. It is stated here and not proved. Its
empirical form was checked at n = 6, where the 20 canonical connected leaves
carry all six atlas indices; see
the accompanying analysis.
The canonical predicate #
A list of naturals is ascending.
Equations
Instances For
BlocksSorted keys values asks that values be ascending across every
adjacent pair whose keys agree. With keys the tail of row 0 and
values row 1, this is cut 1.
Equations
- One or more equations did not get rendered due to their size.
- Utilities.Certificate.CubicMatrixReplay.BlocksSorted x✝¹ x✝ = true
Instances For
The canonical predicate on a row list. It inspects only rows 0 and 1,
so it is decided as soon as those two are chosen.
Equations
- One or more equations did not get rendered due to their size.
- Utilities.Certificate.CubicMatrixReplay.canonicalPrefix [] = true
- Utilities.Certificate.CubicMatrixReplay.canonicalPrefix [row1] = (Utilities.Certificate.CubicMatrixReplay.SortedAsc row1 && true)
Instances For
Only the first two rows matter, so extending a canonical row list on the right cannot break canonicality.
Accepting along a path #
Every nonempty prefix of rows, read after path, is accepted. This is
what a pruned traversal needs in order to reach a given row list.
Equations
Instances For
The pruned traversal #
Exhaustive check that skips branches the accept predicate rejects. A
rejected branch is discharged immediately, so the subtree below it is never
traversed.
Equations
- One or more equations did not get rendered due to their size.
- Utilities.Certificate.CubicMatrixReplay.prunedCheck accept leafDecide 0 x✝¹ x✝ = false
- Utilities.Certificate.CubicMatrixReplay.prunedCheck accept leafDecide n.succ [] x✝ = leafDecide x✝
Instances For
Soundness of the pruned traversal. A row list produced by the
branching whose prefixes are all accepted is accepted by leafDecide. Rows
that fail accept somewhere are deliberately not covered; supplying them is
the job of CanonicalRepresentative.
Canonicality reaches every prefix #
Once rows 0 and 1 are fixed and canonical, every longer path stays
accepted, so a pruned traversal descends all the way.
A canonical row list is accepted along every one of its prefixes. This is
the bridge from the predicate to what prunedCheck_sound consumes.
From index-level inequalities to the Boolean predicates #
Values that ascend across every adjacent pair of equal keys, both read off
the same arithmetic index range, satisfy BlocksSorted.
The two index-level cuts imply the Boolean canonical predicate on the whole row list. This is stated for an arbitrary matrix and vertex count, so the small cases are discharged here rather than assumed away.
A weighted key and the exchange step #
The weighted key of one row of a matrix: entry j carries weight n - j,
so the weights drop by exactly one at every step inside the range. Minimizing
this is the same as minimizing the row lexicographically, but it needs no
lexicographic order on lists.
Equations
- Utilities.Certificate.CubicMatrixReplay.weightKey n F = ∑ j ∈ Finset.range n, (n - j) * F j
Instances For
The exchange step. If G is F with the entries at k and k + 1
interchanged, then the weighted key drops exactly when F descends there, and
is unchanged exactly when F is flat there.
Transporting the matrix along a relabeling #
The multiplicity table of a relabeled core, read at the original vertices. This is the only computation rule the exchange argument needs.
Relabeling by an extra adjacent transposition interchanges the two corresponding rows and columns of the multiplicity table.
The key of a relabeling #
The weighted key of row row of the multiplicity table of core
relabeled along σ.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The exchange step, for a relabeling. Composing with the adjacent
transposition of k and k + 1 interchanges those two entries of any row it
fixes, so it strictly lowers that row's key exactly when the row descends
there, and leaves the key alone when the row is flat there.
Canonical relabeling of a bare core #
Every connected regular ordered core is vertex-relabelled to a core whose first two multiplicity rows satisfy `canonicalPrefix`.