MindFormal v1.0.0One Mind

MindFormal.Tools.A705SharedDescriptions.Residual

MT1.1: the within-block squared residual of a declared finite target on positive-mass atoms, its optimality and uniqueness, the exact positivity criterion and the coarse residual of a finer block's indicator. Targets take values in any real inner product space (a description vector in ℝ^d is the Euclidean case). The weights are the atoms' masses under the actual history law (atom_weights_integral).

noncomputable def MindFormal.A705SharedDescriptions.blockMass {X : Type u_1} [Fintype X] (w : X → ℝ) (P : Setoid X) (z : X) :

The mass of the block of z.

Equations
Instances For
    noncomputable def MindFormal.A705SharedDescriptions.blockSum {X : Type u_1} {E : Type u_2} [Fintype X] [NormedAddCommGroup E] [InnerProductSpace ℝ E] (w : X → ℝ) (P : Setoid X) (f : X → E) (z : X) :
    E

    The weighted sum of the target over the block of z.

    Equations
    Instances For
      noncomputable def MindFormal.A705SharedDescriptions.blockMean {X : Type u_1} {E : Type u_2} [Fintype X] [NormedAddCommGroup E] [InnerProductSpace ℝ E] (w : X → ℝ) (P : Setoid X) (f : X → E) (z : X) :
      E

      The block mean, the best block-constant approximation.

      Equations
      Instances For
        def MindFormal.A705SharedDescriptions.loss {X : Type u_1} {E : Type u_2} [Fintype X] [NormedAddCommGroup E] (w : X → ℝ) (f g : X → E) :

        The weighted squared loss of an approximation g to the target f.

        Equations
        Instances For
          noncomputable def MindFormal.A705SharedDescriptions.residual {X : Type u_1} {E : Type u_2} [Fintype X] [NormedAddCommGroup E] [InnerProductSpace ℝ E] (w : X → ℝ) (P : Setoid X) (f : X → E) :

          MT1.1's residual: the loss of the block mean.

          Equations
          Instances For
            def MindFormal.A705SharedDescriptions.BlockConstant {X : Type u_1} {E : Type u_2} (P : Setoid X) (g : X → E) :

            A block-constant approximation, in the target's space.

            Equations
            Instances For
              theorem MindFormal.A705SharedDescriptions.block_filter_congr {X : Type u_1} {P : Setoid X} {z z' : X} (h : P z z') (y : X) :
              P z y ↔ P z' y
              theorem MindFormal.A705SharedDescriptions.blockMass_congr {X : Type u_1} [Fintype X] {w : X → ℝ} {P : Setoid X} {z z' : X} (h : P z z') :
              blockMass w P z = blockMass w P z'
              theorem MindFormal.A705SharedDescriptions.blockMass_pos {X : Type u_1} [Fintype X] {w : X → ℝ} {P : Setoid X} (hw : ∀ (z : X), 0 < w z) (z : X) :
              0 < blockMass w P z
              theorem MindFormal.A705SharedDescriptions.blockMean_constant {X : Type u_1} {E : Type u_2} [Fintype X] [NormedAddCommGroup E] [InnerProductSpace ℝ E] {w : X → ℝ} {P : Setoid X} (f : X → E) :
              theorem MindFormal.A705SharedDescriptions.tower {X : Type u_1} {E : Type u_2} [Fintype X] [NormedAddCommGroup E] [InnerProductSpace ℝ E] {w : X → ℝ} {P : Setoid X} (hw : ∀ (z : X), 0 < w z) (f h : X → E) (hh : BlockConstant P h) :
              ∑ z : X, w z * inner ℝ (blockMean w P f z) (h z) = ∑ z : X, w z * inner ℝ (f z) (h z)

              The tower identity: averaging against a block-constant function does not see the difference between the target and its block mean.

              theorem MindFormal.A705SharedDescriptions.loss_expansion {X : Type u_1} {E : Type u_2} [Fintype X] [NormedAddCommGroup E] [InnerProductSpace ℝ E] {w : X → ℝ} {P : Setoid X} (hw : ∀ (z : X), 0 < w z) (f g : X → E) (hg : BlockConstant P g) :
              loss w f g = residual w P f + ∑ z : X, w z * ‖blockMean w P f z - g z‖ ^ 2

              The square expansion: any block-constant approximation loses the residual plus the weighted distance to the block mean.

              theorem MindFormal.A705SharedDescriptions.residual_optimal {X : Type u_1} {E : Type u_2} [Fintype X] [NormedAddCommGroup E] [InnerProductSpace ℝ E] {w : X → ℝ} {P : Setoid X} (hw : ∀ (z : X), 0 < w z) (f g : X → E) (hg : BlockConstant P g) :
              residual w P f ≤ loss w f g ∧ (loss w f g = residual w P f ↔ g = blockMean w P f)

              MT1.1: the block mean is the unique optimum among block-constant approximations (atoms have positive mass, so uniqueness is pointwise).

              theorem MindFormal.A705SharedDescriptions.residual_formula {X : Type u_1} {E : Type u_2} [Fintype X] [NormedAddCommGroup E] [InnerProductSpace ℝ E] {w : X → ℝ} {P : Setoid X} (hw : ∀ (z : X), 0 < w z) (f : X → E) :
              residual w P f = ∑ c : Quotient P, (∑ z : X with ⟦z⟧ = c, w z * ‖f z‖ ^ 2 - ‖∑ z : X with ⟦z⟧ = c, w z • f z‖ ^ 2 / blockMass w P c.out)

              MT1.1 in its displayed form: the within-block squared variation.

              theorem MindFormal.A705SharedDescriptions.residual_pos_iff {X : Type u_1} {E : Type u_2} [Fintype X] [NormedAddCommGroup E] [InnerProductSpace ℝ E] {w : X → ℝ} {P : Setoid X} (hw : ∀ (z : X), 0 < w z) (f : X → E) :
              0 ≤ residual w P f ∧ (0 < residual w P f ↔ ∃ (z : X) (z' : X), P z z' ∧ f z ≠ f z')

              The residual is nonnegative and vanishes exactly on block-constant targets: it is positive precisely for a target varying inside a block.

              theorem MindFormal.A705SharedDescriptions.blockMean_of_constant {X : Type u_1} {E : Type u_2} [Fintype X] [NormedAddCommGroup E] [InnerProductSpace ℝ E] {w : X → ℝ} {P : Setoid X} (hw : ∀ (z : X), 0 < w z) {f : X → E} (hf : BlockConstant P f) :
              blockMean w P f = f

              A block-constant target's block mean is itself.

              theorem MindFormal.A705SharedDescriptions.residual_indicator {X : Type u_1} [Fintype X] {w : X → ℝ} {P : Setoid X} (hw : ∀ (z : X), 0 < w z) (z₀ : X) (F : Finset X) (hF : ∀ y ∈ F, P z₀ y) :
              (residual w P fun (y : X) => if y ∈ F then 1 else 0) = (∑ y ∈ F, w y) * (1 - (∑ y ∈ F, w y) / blockMass w P z₀)

              The coarse residual of an indicator of a set inside one block K: μ(F)(1 - μ(F)/μ(K)).

              theorem MindFormal.A705SharedDescriptions.strict_refinement_residual {X : Type u_1} [Fintype X] {w : X → ℝ} {P : Setoid X} (hw : ∀ (z : X), 0 < w z) {Q : Setoid X} (hPQ : P ≤ Q) (hstrict : ¬Q ≤ P) :
              ∃ (z₀ : X), blockIndicator P z₀ ∈ blockSpace P ∧ residual w Q (blockIndicator P z₀) = blockMass w P z₀ * (1 - blockMass w P z₀ / blockMass w Q z₀) ∧ blockMass w P z₀ < blockMass w Q z₀ ∧ 0 < residual w Q (blockIndicator P z₀)

              MT1.1, strict refinement: when P strictly refines Q, a fine block inside a larger coarse block has the exact positive coarse residual μ(F)(1 - μ(F)/μ(K)).

              theorem MindFormal.A705SharedDescriptions.observations_floor {X : Type u_1} {E : Type u_2} [Fintype X] [NormedAddCommGroup E] [InnerProductSpace ℝ E] {w : X → ℝ} {P : Setoid X} (hw : ∀ (z : X), 0 < w z) (f : X → E) {Θ : Type u_3} [MeasurableSpace Θ] (ν : MeasureTheory.Measure Θ) [MeasureTheory.IsProbabilityMeasure ν] (est : Θ → X → E) (hest : ∀ (θ : Θ), BlockConstant P (est θ)) (hint : MeasureTheory.Integrable (fun (θ : Θ) => loss w f (est θ)) ν) :
              (∀ (θ : Θ), residual w P f ≤ loss w f (est θ)) ∧ residual w P f ≤ ∫ (θ : Θ), loss w f (est θ) ∂ν ∧ loss w f (blockMean w P f) = residual w P f

              MT1.1 at fixed target, distribution and representation space: every approximation in the space, however its coefficients were estimated from any further observations θ, loses at least the residual; averaging over the observations' law keeps that floor, which the block mean attains.

              theorem MindFormal.A705SharedDescriptions.atom_weights_integral {X : Type u_1} [Fintype X] {Ω : Type u_3} [MeasurableSpace Ω] (μ : MeasureTheory.Measure Ω) [MeasureTheory.IsFiniteMeasure μ] [MeasurableSpace X] [MeasurableSingletonClass X] (lab : Ω → X) (hlab : Measurable lab) (F : X → ℝ) :
              ∫ (ω : Ω), F (lab ω) ∂μ = ∑ z : X, μ.real (lab ⁻¹' {z}) * F z

              The finite weights are the actual history law's atom masses: an expected function of the declared label is the weighted atom sum.