TorchLean API

NN.MLTheory.CROWN.Proofs.LayerNormDirected

Directed LayerNorm arithmetic #

LayerNorm's variance stage squares a centered interval. An interval crossing zero has lower square bound zero; otherwise the smaller endpoint square is a lower bound. The upper bound is the larger endpoint square. The endpoint products must be rounded in the corresponding direction before either selection.

These facts use the existing real interpretation of directed arithmetic. They compare the computed endpoints with exact real operations, without assuming that ordinary backend addition or multiplication is exact.

Endpoint minimum selects the smaller interpreted real value.

Endpoint maximum selects the larger interpreted real value.

theorem NN.MLTheory.CROWN.Graph.LayerNormDirected.square_le_max {lo x hi : } (hlo : lo x) (hhi : x hi) :
x * x max (lo * lo) (hi * hi)

A scalar square lies below the larger square of any enclosing interval's endpoints.

The directed square interval used by the LayerNorm variance stage encloses every input square.

The zero interpretation is stated explicitly because the base directed-arithmetic class contains order and operation laws, but does not specify the interpretation of scalar literals.

Multiplication by an exact stored scale respects both endpoint orders, including negative scales. The scale itself is interpreted exactly; only endpoint products are directed.

Directed endpoint addition encloses the affine bias shift.