TorchLean API

NN.Tensor.Internal.Check.Normalize

Normalized transformation patterns #

Normalization expands ellipses against a statically known input rank and replaces surface axes by stable elementary-axis identifiers. The result carries the rank and operation-specific well-formedness facts needed by later checking and semantics.

The three transformation modes with distinct axis-set rules.

  • rearrange : TransformKind

    Permute and reshape axes without creating or reducing elements.

  • repeat : TransformKind

    Insert and replicate axes while preserving every input axis.

  • reduce : TransformKind

    Remove input axes with an explicitly chosen reduction.

Instances For

    Stable identity of an elementary axis after ellipsis expansion.

    • named (name : String) : AxisId

      A logical axis identified by its source name.

    • anonymous (value occurrence : ) : AxisId

      A numeric axis identified by both its length and source occurrence.

    • ellipsis (index : ) : AxisId

      One concrete dimension generated by expanding an ellipsis.

    Instances For
      @[implicit_reducible]

      Whether an axis is an anonymous numeric occurrence.

      Instances For
        @[implicit_reducible]

        Expand one parsed axis into its elementary normalized axes.

        This helper is exposed only because elaborated transformation certificates reduce expandExpression in downstream modules.

        Instances For
          @[implicit_reducible]

          Whether a physical axis consists solely of an unparenthesized ellipsis.

          The distinction matters because a bare ellipsis contributes several physical dimensions, whereas a parenthesized ellipsis remains one composite dimension.

          Instances For
            @[implicit_reducible]

            Expand one composition, splitting a bare ellipsis into separate dimensions.

            Instances For
              @[implicit_reducible]

              Expand every composition in an expression against rank-generated ellipsis axes.

              Instances For
                @[implicit_reducible]

                Whether every elementary axis in left also occurs in right.

                Instances For
                  theorem TorchLean.Tensor.Internal.Check.axesSubset_eq_true_iff {left right : List AxisId} :
                  axesSubset left right = true ∀ ⦃axis : AxisId⦄, axis leftaxis right

                  The Boolean subset test exactly expresses list-element containment.

                  @[implicit_reducible]

                  Whether a normalized axis list contains a numeric anonymous axis.

                  This helper remains under Internal; its body is visible so generated well-formedness certificates can reduce anonymousAxesAllowed.

                  Instances For

                    A transformation pattern after rank-specific ellipsis expansion.

                    • Operation whose axis-set rules the normalized pattern must satisfy.

                    • Original parsed pattern, retained for diagnostics and source conventions.

                    • input : Shape

                      Physical input against which the left side was normalized.

                    • ellipsisRank :

                      Number of physical dimensions represented by the input ellipsis.

                    • ellipsisAxes : List AxisId

                      Fresh logical axes replacing the ellipsis, in physical order.

                    • inputGroups : List (List AxisId)

                      Elementary input axes grouped by physical input dimension.

                    • outputGroups : List (List AxisId)

                      Elementary output axes grouped by physical output dimension.

                    Instances For
                      @[implicit_reducible]

                      Elementary input axes in source order.

                      Instances For
                        @[implicit_reducible]

                        Elementary output axes in source order.

                        Instances For
                          @[implicit_reducible]

                          The axis-set condition associated with the selected transformation mode.

                          Instances For
                            @[implicit_reducible]

                            Whether the mode permits all anonymous axes present in the pattern.

                            Instances For
                              @[implicit_reducible]

                              The rank equation determining the number of expanded ellipsis axes.

                              Instances For
                                @[instance_reducible]

                                The ellipsis rank equation is constructively decidable from the finite pattern and shape data.

                                All structural facts established by normalization.

                                Instances For
                                  theorem TorchLean.Tensor.Internal.Check.NormalizedTransform.Valid.input_axes_subset_output_of_rearrange {normalized : NormalizedTransform} (valid : normalized.Valid) (hKind : normalized.kind = TransformKind.rearrange) axis : AxisId :
                                  axis normalized.inputAxesaxis normalized.outputAxes

                                  Rearrange preserves every input elementary axis in its output.

                                  theorem TorchLean.Tensor.Internal.Check.NormalizedTransform.Valid.output_axes_subset_input_of_rearrange {normalized : NormalizedTransform} (valid : normalized.Valid) (hKind : normalized.kind = TransformKind.rearrange) axis : AxisId :
                                  axis normalized.outputAxesaxis normalized.inputAxes

                                  Rearrange introduces no output elementary axis absent from its input.

                                  theorem TorchLean.Tensor.Internal.Check.NormalizedTransform.Valid.input_axes_subset_output_of_repeat {normalized : NormalizedTransform} (valid : normalized.Valid) (hKind : normalized.kind = TransformKind.repeat) axis : AxisId :
                                  axis normalized.inputAxesaxis normalized.outputAxes

                                  Repeat retains every input elementary axis and may add new output axes.

                                  theorem TorchLean.Tensor.Internal.Check.NormalizedTransform.Valid.output_axes_subset_input_of_reduce {normalized : NormalizedTransform} (valid : normalized.Valid) (hKind : normalized.kind = TransformKind.reduce) axis : AxisId :
                                  axis normalized.outputAxesaxis normalized.inputAxes

                                  Reduce retains only elementary axes already present in its input.

                                  A normalized pattern bundled with its machine-checked invariant.

                                  • Normalized transformation data consumed by shape resolution.

                                  • valid : self.value.Valid

                                    Proof that normalization established every structural invariant.

                                  Instances For

                                    Expand a parsed transformation pattern against a concrete input rank.

                                    The returned proof records rank agreement, ellipsis expansion, uniqueness of elementary axes, and the mode-specific axis relation.

                                    Instances For