TorchLean API

NN.MLTheory.Proofs.Hopfield.Energy

Hopfield energy: single-step dynamics (spec layer) #

This file proves the key “global dynamics” lemma from the Hopfield literature:

Under symmetric, zero-diagonal weights, the Hopfield energy is non-increasing under an asynchronous update.

We work over , where the classical energy argument is algebraic. The executable Hopfield implementation uses ExecFloat.Binary 8 23; floating-point executions are connected to this theorem only through explicit runtime/rounding bridge statements, not by silently reusing real arithmetic laws.

Symmetry condition on Hopfield weights: W i j = W j i.

Instances For

    Zero-diagonal condition on Hopfield weights: W i i = 0.

    Instances For
      noncomputable def NN.MLTheory.Proofs.Hopfield.x {n : } (s : Spec.Hopfield.State n) :
      Fin n

      Bipolar activation vector of a state, ±1 per unit.

      Instances For
        noncomputable def NN.MLTheory.Proofs.Hopfield.U {n : } :

        The index set of all units, named so the sums below read like the paper.

        Instances For
          noncomputable def NN.MLTheory.Proofs.Hopfield.netx {n : } (p : Spec.Hopfield.Params n) (x : Fin n) (u : Fin n) :

          Net input at u, written as a function of the activation vector rather than the Boolean state.

          The energy computations are all linear algebra over , so working with x instead of s keeps Function.update and Finset.sum lemmas applicable throughout.

          Instances For
            noncomputable def NN.MLTheory.Proofs.Hopfield.quad {n : } (p : Spec.Hopfield.Params n) (x : Fin n) :

            The quadratic form ∑ᵢⱼ Wᵢⱼ xᵢ xⱼ.

            Instances For
              noncomputable def NN.MLTheory.Proofs.Hopfield.energyU {n : } (p : Spec.Hopfield.Params n) (x : Fin n) :

              Energy as a function of the activation vector: -½ xᵀWx + θᵀx.

              Instances For

                The state-level energy and the vector-level one agree.

                Likewise for the net input.

                An update of the state becomes a Function.update of the activation vector.

                theorem NN.MLTheory.Proofs.Hopfield.netx_update_eq {n : } (p : Spec.Hopfield.Params n) (x0 : Fin n) (u : Fin n) (xu' : ) :
                netx p (Function.update x0 u xu') u = netx p x0 u + p.W u u * (xu' - x0 u)

                Changing coordinate u shifts the net input at u only through the self-weight W u u, which the zero-diagonal hypothesis later kills.

                theorem NN.MLTheory.Proofs.Hopfield.quad_inner_delta_ne {n : } (p : Spec.Hopfield.Params n) {u i : Fin n} (hi : i u) (x0 : Fin n) (xu' : ) :
                jU, p.W i j * x0 i * Function.update x0 u xu' j - jU, p.W i j * x0 i * x0 j = p.W i u * x0 i * (xu' - x0 u)

                Contribution of a single row i ≠ u to the change in the quadratic form.

                theorem NN.MLTheory.Proofs.Hopfield.quad_delta_update {n : } (p : Spec.Hopfield.Params n) (hsym : SymmetricW p) (hdiag : DiagonalZero p) (x0 : Fin n) (u : Fin n) (xu' : ) :
                quad p (Function.update x0 u xu') - quad p x0 = 2 * (xu' - x0 u) * netx p x0 u

                Change in the quadratic form under a single-unit update: 2 (x'ᵤ - xᵤ) · netᵤ.

                Symmetry is what merges the row and column contributions into a single factor of two, and the zero diagonal is what removes the term where the unit acts on itself. Without either hypothesis the energy can increase and the network need not converge.

                A single asynchronous update never increases the energy.

                Exact energy change of one update: -(x'ᵤ - xᵤ)(netᵤ - θᵤ).

                The sign is forced: the update sets x'ᵤ to agree with the sign of netᵤ - θᵤ, so the product is nonnegative and the energy change is nonpositive. Everything else in this file is a corollary.

                Exactly at the threshold the energy does not move, which is the flat case the active-unit counter has to handle.

                Away from the threshold, a state change strictly lowers the energy.