Sites, one-step shift, and total power on a periodic -dimensional lattice
DefinitionPassivityTorus_powerFix natural numbers , and . A site is a point of the periodic cubic lattice with axes and sites along each. Moving steps along axis changes only coordinate , to modulo ; write for one step forward or back.
Each link carries a real matrix and each site a velocity . The total power of the neighbour coupling is
where the second term uses the matrix of the link behind .
Formalization Note Sites are Fin q → Fin L; the step is Function.update on one coordinate with Fin L arithmetic, which wraps around. [NeZero L] is needed for the literal in Fin L.
import Mathlib
open Matrix BigOperators
namespace PassivityTorus
/-- Sites of a periodic cubic lattice with q axes and L sites along each. -/
abbrev Site (q L : ℕ) := Fin q → Fin L
/-- Move s steps along axis a, wrapping around. -/
def shift {q L : ℕ} (x : Site q L) (a : Fin q) (s : Fin L) : Site q L :=
Function.update x a (x a + s)
/-- Total power of the per-link neighbour coupling. -/
def power (q L d : ℕ) [NeZero L]
(W : Site q L → Fin q → Matrix (Fin d) (Fin d) ℝ)
(v : Site q L → (Fin d → ℝ)) : ℝ :=
∑ x : Site q L, ∑ a : Fin q,
v x ⬝ᵥ (W x a *ᵥ v (shift x a 1) - W (shift x a (-1)) a *ᵥ v (shift x a (-1)))
end PassivityTorus
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Sites. For natural numbers and , a site is a function , i.e. an element of , the discrete -dimensional torus with side . Coordinates take values in , and all addition and negation of coordinates is modulo . No constraint on or is made at this stage. If there is exactly one site (the empty function). If and there are no sites.
Shift. For a site , a direction and an amount , is the site that agrees with in every coordinate and has -th coordinate :
Write and . Here is the residue of modulo and is its additive inverse modulo , i.e. the residue . The shift wraps around: if then , and if then . In the degenerate case we have , so . When we have , so .
Power. The function takes explicit natural numbers , the assumption (which is what gives the residue above its meaning), and two further arguments:
- , which assigns to every site and direction an arbitrary real matrix . Nothing is assumed about these matrices: no symmetry, definiteness, invertibility, or relation between different .
- , which assigns to every site an arbitrary real vector .
It returns the real number
Here is the plain real dot product , with no conjugation or transpose, and is the ordinary matrix-vector product . The first term uses the matrix at the site itself, and the second uses the matrix at the neighbouring site , both in the same direction . Both sums are finite and range over all sites and all directions.
Degenerate cases. If the inner sum is empty, so . If every dot product is empty, so . If then , each summand is , and so . If the two neighbours and are the same site. The file defines only these objects and asserts no properties about them.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.