Documentation

CslibFrontier.Foundations.Data.Matrix.HamiltonianCycle

The Hamiltonian cycle sum of a matrix #

The Hamiltonian cycle sum of a square matrix M over a commutative semiring is ∑ σ, ∏ i, M i (σ i), the sum over the permutations σ that are one cycle through all indices. Read M i j as the weight of the edge from i to j of a complete directed graph; the sum is then the total weight of its Hamiltonian cycles. Like the permanent, which sums over all permutations, it is unchanged by renaming the indices (hamiltonianCycleSum_submatrix_equiv) and commutes with ring homomorphisms. Over Fin (k + 1), a cycle through all indices is the order in which it visits them from 0 on (hamiltonianCycleSum_eq_sum_orders).

Main definitions #

Main results #

References #

noncomputable def Matrix.hamiltonianCycleSum {n : Type u_2} [Fintype n] [DecidableEq n] {R : Type u_3} [CommSemiring R] (M : Matrix n n R) :
R

The Hamiltonian cycle sum of a square matrix: the sum, over the permutations σ that form a single cycle through all indices, of ∏ i, M i (σ i).

theorem RingHom.map_hamiltonianCycleSum {n : Type u_2} [Fintype n] [DecidableEq n] {R : Type u_3} [CommSemiring R] {S : Type u_4} [CommSemiring S] (f : R →+* S) (M : Matrix n n R) :

Applying a ring homomorphism to the Hamiltonian cycle sum of a matrix is the Hamiltonian cycle sum of the mapped matrix.

theorem AlgHom.map_hamiltonianCycleSum {n : Type u_2} [Fintype n] [DecidableEq n] {R₀ : Type u_4} {A : Type u_5} {B : Type u_6} [CommSemiring R₀] [CommSemiring A] [CommSemiring B] [Algebra R₀ A] [Algebra R₀ B] (f : A →ₐ[R₀] B) (M : Matrix n n A) :

Applying an algebra homomorphism to the Hamiltonian cycle sum of a matrix is the Hamiltonian cycle sum of the mapped matrix.

@[simp]
theorem Matrix.hamiltonianCycleSum_submatrix_equiv {m : Type u_1} {n : Type u_2} [Fintype m] [DecidableEq m] [Fintype n] [DecidableEq n] {R : Type u_3} [CommSemiring R] (e : m ≃ n) (M : Matrix n n R) :

Renaming the indices of a square matrix does not change its Hamiltonian cycle sum.

theorem Matrix.hamiltonianCycleSum_eq_sum_orders {R : Type u_3} [CommSemiring R] {k : ℕ} (M : Matrix (Fin (k + 1)) (Fin (k + 1)) R) :
M.hamiltonianCycleSum = ∑ π : Equiv.Perm (Fin (k + 1)) with π 0 = 0, ∏ i : Fin (k + 1), M (π i) (π ((finRotate (k + 1)) i))

A Hamiltonian cycle is an order of the indices. Over Fin (k + 1), every cycle through all indices visits them in exactly one order π with π 0 = 0, and the cycle sends π i to π (i + 1).