Documentation

LambdaS.RatioCompare

Fuel-free comparison of open first-order ratios #

Every scalar component of a first-order context receives its own fresh unit variable. Tw.nf evaluates in that symbolic environment by structural recursion: internal functions, higher-order applications, and unit binders impose no fuel bound. Unknown function and unit-family inputs are outside this interface. The correctness and exactness statements quantify over arbitrary positive input drifts, not an all-ones environment. The normal form is Tw.openNF; Tw.openNF_eq_iff is the exactness theorem, and Tw.normEq (in LambdaS.Twist) uses it at first-order contexts.

Shapes whose unknown values have finitely many independent scalar components.

Equations
Instances For
    @[reducible]

    Number of independent scalar components. Higher-order inputs are excluded.

    Equations
    Instances For

      Reconstruct a value from its scalar components.

      Equations
      Instances For

        Read scalar components out of a value.

        Equations
        Instances For
          theorem LambdaS.Shape.decode_encode (s : Shape) (h : s.firstOrder = true) (v : SemTw s) :
          s.decode (s.encode v) = v

          Component reconstruction preserves every first-order value.

          def LambdaS.Shape.reflect {B : Type} {k : ℕ} (s : Shape) :
          (Fin s.cells → UExp B k) → SynTw B k s

          Reflect symbolic scalar components at their shape.

          Equations
          Instances For
            theorem LambdaS.Shape.reflect_correct {B : Type} [Fintype B] {k : ℕ} (ψ : Scaling B k) (s : Shape) (f : Fin s.cells → UExp B k) :
            SRel ψ s (s.reflect f) (s.decode fun (i : Fin s.cells) => ⟨ψ.scale (f i), ⋯⟩)

            Reflection respects the symbolic logical relation.

            @[reducible]

            Total number of independent context components.

            Equations
            Instances For

              A first-order context may contain scalars, vectors and matrices, but no functions or unit families.

              Equations
              Instances For

                Reconstruct an environment from independent scalar components.

                Equations
                Instances For

                  Read all scalar components of a context.

                  Equations
                  Instances For

                    No information is lost for first-order contexts.

                    def LambdaS.reflectRatioEnv {B : Type} {k : ℕ} (Θ : List Shape) :
                    (Fin (ratioCells Θ) → UExp B k) → SynEnv B k Θ

                    Reflect a context using distinct symbolic scalar components.

                    Equations
                    Instances For
                      theorem LambdaS.reflectRatioEnv_correct {B : Type} [Fintype B] {k : ℕ} (ψ : Scaling B k) (Θ : List Shape) (f : Fin (ratioCells Θ) → UExp B k) :
                      SRelEnv ψ Θ (reflectRatioEnv Θ f) (decodeRatioEnv Θ fun (i : Fin (ratioCells Θ)) => ⟨ψ.scale (f i), ⋯⟩)

                      Context reflection is related to its componentwise interpretation.

                      def LambdaS.Tw.openNF {B : Type} {k : ℕ} {Θ : List Shape} (t : Tw B k Θ Shape.scalar) :
                      UExp B (k + ratioCells Θ)

                      Fuel-free scalar normal form, with fresh coordinates for every input component. Exactness for arbitrary environments requires ratioFirstOrder Θ = true.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        def LambdaS.ratioUnitScaling {B : Type} {k : ℕ} {Θ : List Shape} (χ : Scaling B (k + ratioCells Θ)) :

                        Split the enlarged scaling into the original unit scope.

                        Equations
                        Instances For
                          noncomputable def LambdaS.ratioInputEnv {B : Type} {k : ℕ} (Θ : List Shape) (χ : Scaling B (k + ratioCells Θ)) :

                          Interpret the fresh coordinates as independent positive input drifts.

                          Equations
                          Instances For
                            theorem LambdaS.Tw.openNF_correct {B : Type} [Fintype B] {k : ℕ} {Θ : List Shape} (t : Tw B k Θ Shape.scalar) (χ : Scaling B (k + ratioCells Θ)) :
                            ↑(eval (ratioUnitScaling χ) t (ratioInputEnv Θ χ)) = χ.scale t.openNF

                            Correctness under every assignment of original and fresh coordinates.

                            noncomputable def LambdaS.extendRatioScaling {B : Type} {k : ℕ} {Θ : List Shape} (ψ : Scaling B k) (ρ : TwEnv Θ) :

                            Extend any original scaling with the logarithms of the actual input drifts.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              @[simp]
                              theorem LambdaS.ratioUnitScaling_extend {B : Type} {k : ℕ} {Θ : List Shape} (ψ : Scaling B k) (ρ : TwEnv Θ) :

                              Restriction recovers the original unit scaling.

                              @[simp]
                              theorem LambdaS.ratioInputEnv_extend {B : Type} {k : ℕ} {Θ : List Shape} (h : ratioFirstOrder Θ = true) (ψ : Scaling B k) (ρ : TwEnv Θ) :

                              Every first-order environment is represented by fresh coordinates.

                              theorem LambdaS.Tw.openNF_sound {B : Type} [Fintype B] {k : ℕ} {Θ : List Shape} (a b : Tw B k Θ Shape.scalar) (hΘ : ratioFirstOrder Θ = true) (h : a.openNF = b.openNF) (ψ : Scaling B k) (ρ : TwEnv Θ) :
                              eval ψ a ρ = eval ψ b ρ

                              Equal open normal forms agree at arbitrary positive first-order inputs.

                              theorem LambdaS.Tw.openNF_eq_iff {B : Type} [Fintype B] {k : ℕ} {Θ : List Shape} (a b : Tw B k Θ Shape.scalar) (hΘ : ratioFirstOrder Θ = true) :
                              a.openNF = b.openNF ↔ ∀ (ψ : Scaling B k) (ρ : TwEnv Θ), eval ψ a ρ = eval ψ b ρ

                              Exactness includes all internal higher-order applications and unit binders; only the unknown input context must be first-order.