Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

**Positional encodings break permutation symmetry exactly on the non-stabilizing

Proved
PositionalSymmetry.posScore_equivariant_iff

by raver1975 · Sep 12, 2026 · Mathlib c5ea003 (Lean v4.30.0)

aether-catalogmachinelearning

Positional encodings break permutation symmetry exactly on the non-stabilizing permutations. For at least two tokens, σ preserves every positionally-encoded score for every input if and only if σ fixes the positional encoding pointwise.

theorem PositionalSymmetry.posScore_equivariant_iff(hcard : 2 ≤ Fintype.card ι)
    (σ : Equiv.Perm ι) (p : ι → κ → ℝ) :
    (∀ x : ι → κ → ℝ, ∀ i j, posScore p (permute σ x) (σ i) (σ j) = posScore p x i j)
      ↔ ∀ i, p (σ i) = p i := by sorry

Formalization Note Transplanted verbatim from the Aether Catalog source MachineLearning/TransformerUniversality/PositionalSymmetry.lean; the statement is byte-identical to the source declaration, elaborated with autoImplicit disabled in the platform environment.

Preamble
-- Thm stub generated from MachineLearning/TransformerUniversality/PositionalSymmetry.lean
import Mathlib
import Definitions.Def_MachineLearning_TransformerUniversality_PositionalSymmetry

/-!
# Permutation symmetry and how additive positional encodings destroy it

`Catalog/MachineLearning/SoftmaxAttentionEquivariance.lean` proves that softmax attention is
permutation equivariant, and `Catalog/MachineLearning/TransformerArchitecture.lean` introduces
additive positional encodings but proves nothing about the interaction of the two.  This file
determines that interaction **exactly**.

Working with the bilinear (pre-softmax) attention score of the catalog architecture, we show:

* `linAttention_equivariant` — with no positional encoding, the whole attention read is
  equivariant under every simultaneous token permutation;
* `posScore_equivariant_iff` — with an additive positional encoding `p`, a permutation `σ`
  preserves all scores for all inputs **iff** `p ∘ σ = p`;
* `posStab` — consequently the residual symmetry group is exactly the stabilizer subgroup of
  the positional encoding, and `mem_posStab_iff` identifies it with the equivariant
  permutations;
* `posStab_eq_bot_of_injective` — pairwise distinct positional encodings destroy *all*
  permutation symmetry;
* `exists_symmetry_breaking` and `two_token_symmetry_breaking` — an explicit two-token
  counterexample.
-/

open scoped BigOperators

open PositionalSymmetry

variable {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ]
Formal statement
theorem PositionalSymmetry.posScore_equivariant_iff(hcard : 2 ≤ Fintype.card ι)
    (σ : Equiv.Perm ι) (p : ι → κ → ℝ) :
    (∀ x : ι → κ → ℝ, ∀ i j, posScore p (permute σ x) (σ i) (σ j) = posScore p x i j)
      ↔ ∀ i, p (σ i) = p i := by sorry
Source
https://github.com/paulklemstine/Lean/blob/53c2925a02/Catalog/MachineLearning/TransformerUniversality/PositionalSymmetry.lean#L63

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me