A Property Kind Calculus for Measurement Metrology

15.6. The weighted mean, and its license🔗

A third aggregation mode, neither additive nor constant. Its side condition is the one a formula written without it silently violates — where a centre of mass defined as a ratio of integrals with no mass hypothesis returns the origin for a massless body.

Definition15.6.1
Group: Mass is extensive: the mass of a whole is the sum of the masses of its parts. Volume on mixing is not: ethanol and water mix sub-additively. Tracking which kinds are extensive is a precondition for soundly aggregating measurements. (30)
Group member previews
Preview
Definition 15.1.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 0
Used by 7
Reverse dependency previews
Preview
Theorem 10.1.9
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

A weighted carving is a carving, a weight per part, and the license the mean needs: the total weight is not zero. Carrying the condition as a field is the point — a whole with no weight is not a term of the type, so the degenerate case is unreachable rather than handled.

Lean code for Definition15.6.1●1 definition
  • structure(3 fields)defined in PropertyKindCalculus/Aggregation.lean
    complete
    structure PropertyKindCalculus.WeightedCarving.{u} (R : Type) (P : Type u)
      [PropertyKindCalculus.Carrier R] : Type u
    structure PropertyKindCalculus.WeightedCarving.{u}
      (R : Type) (P : Type u)
      [PropertyKindCalculus.Carrier R] :
      Type u
    A **weighted carving** at carrier `R`: parts, a weight for each, and the license the mean
    needs. The third field is the whole point — a mean is not a function of the parts alone, and the
    denominator is where that shows. A carving with no weight is not a term of this type: where a
    formula defined without the hypothesis silently returns the origin for a massless body, there is
    here nothing to return it from.
    
    What the license *licenses* depends on the carrier; the module docstring says how far each of
    this library's three carriers takes it. 
    parts : PropertyKindCalculus.Decomposition P
    How the whole is carved. 
    weight : P → R
    The weight of each part — mass, for a centre of mass. 
    total_ne_zero : PropertyKindCalculus.totalWeight self.weight self.parts ≠ PropertyKindCalculus.Carrier.zero
    **The license**: the total weight is not the carrier's zero. 
Proof for Definition 15.6.1
uses 0

Realized as WeightedCarving R P in the Mathlib-free core (Aggregation), carried at whatever numbers the task uses: WeightedCarving.mean is the ratio of the weighted fold to the weight fold, and needs the carrier's * and / beside the + every mode needs. What cannot live there is the mode's law — see below.

Definition15.6.2
Group: Mass is extensive: the mass of a whole is the sum of the masses of its parts. Volume on mixing is not: ethanol and water mix sub-additively. Tracking which kinds are extensive is a precondition for soundly aggregating measurements. (30)
Group member previews
Preview
Definition 15.1.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 0used by 0✓L∃∀N

The license decided rather than assumed. A program does not hold a proof that its weights sum to something nonzero; it holds the weights. The run-time constructor tests the total and either produces the carving — license included — or refuses. The refusal is the value a formula written without the hypothesis would have had to invent.

Lean code for Definition15.6.2●1 definition
  • defdefined in PropertyKindCalculus/Aggregation.lean
    complete
    def PropertyKindCalculus.WeightedCarving.mk?.{u} {R : Type} {P : Type u}
      [PropertyKindCalculus.Carrier R] [DecidableEq R]
      (parts : PropertyKindCalculus.Decomposition P) (weight : P → R) :
      Option (PropertyKindCalculus.WeightedCarving R P)
    def PropertyKindCalculus.WeightedCarving.mk?.{u}
      {R : Type} {P : Type u}
      [PropertyKindCalculus.Carrier R]
      [DecidableEq R]
      (parts :
        PropertyKindCalculus.Decomposition P)
      (weight : P → R) :
      Option
        (PropertyKindCalculus.WeightedCarving
          R P)
    **The license, decided rather than assumed.** A program does not have a proof that its
    weights sum to something nonzero; it has the weights. `mk?` runs the carrier's own equality test
    on the total and either produces the carving — license included — or refuses. The refusal is the
    value that a formula without the hypothesis would have had to invent.
    
    The test is the carrier's `DecidableEq`, so what `mk?` rejects is exactly what the carrier calls
    zero. At `Float` that is a narrower set than the weights a mean should refuse (`NaN` passes),
    which is not a defect of this constructor but the reason an executable rung states its own gate:
    TorchLean's own `NF.checkedDiv` guards the same division on `b.val = 0`, and a soil or radiance
    kernel guards it on a valid-sample *count* long before either. 
Proof for Definition 15.6.2

WeightedCarving.mk? is a dif on the carrier's own equality test, and mk?_eq_none_iff says it refuses exactly the carvings whose total is the carrier's zero. Uses weighted carvings.

What the test rejects is what the carrier calls zero, and that is where the ladder starts mattering. At Float the license is satisfied by NaN: an all-NaN carving is accepted and its mean of a constant is NaN, refuting at that carrier the law proved below. Nothing is wrong with the field; what is absent is a carrier law to spend it on, which is why the executable rungs state their own gate rather than inherit this one.

Theorem15.6.3
Group: Mass is extensive: the mass of a whole is the sum of the masses of its parts. Volume on mixing is not: ethanol and water mix sub-additively. Tracking which kinds are extensive is a precondition for soundly aggregating measurements. (30)
Group member previews
Preview
Definition 15.1.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1used by 0✓L∃∀N

The mean of a constant is that constant. Put every part at the same place and the whole is at that place, whatever the weights — the law that distinguishes this mode from a sum and from a shared reading at once. Uses weighted carvings.

Lean code for Theorem15.6.3●1 theorem
  • theoremdefined in PropertyKindCalculus/AggregationLaws.lean
    complete
    theorem PropertyKindCalculus.WeightedCarving.mean_const.{u} {P : Type u}
      (c : PropertyKindCalculus.WeightedCarving ℝ P) (v : ℝ) :
      (c.mean fun x => v) = v
    theorem PropertyKindCalculus.WeightedCarving.mean_const.{u}
      {P : Type u}
      (c :
        PropertyKindCalculus.WeightedCarving ℝ
          P)
      (v : ℝ) : (c.mean fun x => v) = v
    **The mean of a constant is that constant.** The law that distinguishes this mode from a
    sum and from a shared constant at once: put every part at the same place and the whole is at
    that place, whatever the weights. The proof uses the license, which is why it is a field — and
    it uses cancellation, which is why the law is here and the structure is in the core. 
Proof for Theorem 15.6.3
uses 0

A constant factors out of the fold (fold_mul_const, by induction), and the license discharges the cancellation. Cancellation is a field law, which is why this statement is in the PhysLib-backed AggregationLaws over \mathbb{R} while the mode it is about is in the core: the structure travels down to every carrier and the law stops at the lawful ones.

That the weights are load-bearing is checked separately: a carving weighted 1 and 3 over values 3 and 1 has mean 3/2 where the unweighted average of the same values is 2, so a mean ignoring its weights would fail the probe.

Theorem15.6.4
Group: Mass is extensive: the mass of a whole is the sum of the masses of its parts. Volume on mixing is not: ethanol and water mix sub-additively. Tracking which kinds are extensive is a precondition for soundly aggregating measurements. (30)
Group member previews
Preview
Definition 15.1.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1used by 1✓L∃∀N

The binary32 weighted mean is within the evaluation DAG's rounding budget of the exact one. The rung between the mode and its law: at genuine binary32 the mean is computed on a rounded grid, so the constant law holds only up to an accumulated budget, and the theorem says what that budget is. Uses weighted carvings.

Lean code for Theorem15.6.4●1 theorem
  • theoremdefined in PropertyKindCalculus/Uncertainty/Adequacy/MeanBound.lean
    complete
    theorem PropertyKindCalculus.Uncertainty.Adequacy.mean_fp32_within_errBound.{u}
      {P : Type u}
      (c : PropertyKindCalculus.WeightedCarving TorchLean.Floats.FP32 P)
      (v : P → TorchLean.Floats.FP32) (ρ : ℕ → TorchLean.Floats.FP32)
      (hS :
        PropertyKindCalculus.totalWeight (fun p => (c.weight p).val)
            c.parts ≠
          PropertyKindCalculus.Carrier.zero) :
      |(c.mean v).val -
            (PropertyKindCalculus.Uncertainty.Adequacy.specCarving c
                  hS).mean
              fun p => (v p).val| ≤
        PropertyKindCalculus.Uncertainty.Adequacy.errBound
          (PropertyKindCalculus.Uncertainty.Adequacy.meanExpr c.weight v
            c.parts)
          ρ
    theorem PropertyKindCalculus.Uncertainty.Adequacy.mean_fp32_within_errBound.{u}
      {P : Type u}
      (c :
        PropertyKindCalculus.WeightedCarving
          TorchLean.Floats.FP32 P)
      (v : P → TorchLean.Floats.FP32)
      (ρ : ℕ → TorchLean.Floats.FP32)
      (hS :
        PropertyKindCalculus.totalWeight
            (fun p => (c.weight p).val)
            c.parts ≠
          PropertyKindCalculus.Carrier.zero) :
      |(c.mean v).val -
            (PropertyKindCalculus.Uncertainty.Adequacy.specCarving
                  c hS).mean
              fun p => (v p).val| ≤
        PropertyKindCalculus.Uncertainty.Adequacy.errBound
          (PropertyKindCalculus.Uncertainty.Adequacy.meanExpr
            c.weight v c.parts)
          ρ
    **The binary32 weighted mean is within the DAG's rounding budget of the exact one.** For a
    carving carried at TorchLean's binary32 rounding spec, and given the specification carrier's own
    nonzero-total license, the mean computed on the grid — forgotten to `ℝ` — differs from the exact
    real mean of the same weights and values by at most `errBound` of the compiled mean DAG.
    
    This is `dag_fp32_error_bound` at the one expression shape the aggregation modes could not reach:
    `Extensivity`'s extensive mode is a fold and needs only `+`, while a mean multiplies, sums and
    finally divides, and it is the division that makes the budget's quotient-rule factors — `1/|b|`
    for the numerator's accumulated error, `|a|/|b|²` for the denominator's — the price of a small
    total weight. A carving whose weights nearly cancel has a license, an exact mean, and a budget
    that says how little the computed one is worth. 
Proof for Theorem 15.6.4
uses 0

A mean is the first aggregation mode that is not a fold — it multiplies, sums, and finally divides — so it is exactly the shape the adequacy layer's forward-error theorem (dag_fp32_error_bound) was built for. MeanBound compiles a carving into that layer's Expr (weights and values as exact binary32 constants, the folds as add nodes, the ratio as the one div node) and reads the bound off it. Every rounding the mean incurs is a node of the budget, and the quotient rule's magnitude factors are what a small total weight costs.

The load-bearing detail is that the license does not cross the bridge. WeightedCarving's field says the total is not the carrier's zero, which at binary32 is a statement about the rounded fold; the theorem also needs one about the exact fold, and neither implies the other. Both directions are ordinary floating-point behavior and both are exhibited: weights 2^{24}, 1, -2^{24} sum exactly to 1 while their binary32 fold is exactly +0, because the first addition absorbs the 1; and weights 2^{24}, 1, 1, -(2^{24}+2) sum exactly to 0 while their binary32 fold is exactly -2, because two absorbed 1s leave the running total short. So forgetting a binary32 carving to the real carving it specifies takes the specification's license as an argument, and the signature is where that is recorded.

Theorem15.6.5
Group: Mass is extensive: the mass of a whole is the sum of the masses of its parts. Volume on mixing is not: ethanol and water mix sub-additively. Tracking which kinds are extensive is a precondition for soundly aggregating measurements. (30)
Group member previews
Preview
Definition 15.1.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 2
Reverse dependency previews
Preview
Theorem 15.6.9
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

A denominator that is never rounded has one license, not two. Where the refinement's rounding is the identity, forgetting a carving's total gives the total of the forgotten weights, so the executable condition and the specification's are the same statement read through the forgetful map — and a run-time test of the computed total is a test of the quantity being defined. Uses weighted carvings.

Lean code for Theorem15.6.5●1 theorem
  • theoremdefined in PropertyKindCalculus/Aggregation.lean
    complete
    theorem PropertyKindCalculus.licenses_agree_of_exact.{u} {E S : Type}
      {P : Type u} [PropertyKindCalculus.Carrier E]
      [PropertyKindCalculus.Carrier S]
      [PropertyKindCalculus.CarrierRefinement E S]
      (hround :
        ∀ (s : S), PropertyKindCalculus.CarrierRefinement.round E s = s)
      (hzero :
        ∀ (x : E),
          PropertyKindCalculus.CarrierRefinement.toSpec x =
              PropertyKindCalculus.Carrier.zero →
            x = PropertyKindCalculus.Carrier.zero)
      (w : P → E) (d : PropertyKindCalculus.Decomposition P) :
      PropertyKindCalculus.totalWeight w d ≠
          PropertyKindCalculus.Carrier.zero ↔
        PropertyKindCalculus.totalWeight
            (fun p => PropertyKindCalculus.CarrierRefinement.toSpec (w p))
            d ≠
          PropertyKindCalculus.Carrier.zero
    theorem PropertyKindCalculus.licenses_agree_of_exact.{u}
      {E S : Type} {P : Type u}
      [PropertyKindCalculus.Carrier E]
      [PropertyKindCalculus.Carrier S]
      [PropertyKindCalculus.CarrierRefinement
          E S]
      (hround :
        ∀ (s : S),
          PropertyKindCalculus.CarrierRefinement.round
              E s =
            s)
      (hzero :
        ∀ (x : E),
          PropertyKindCalculus.CarrierRefinement.toSpec
                x =
              PropertyKindCalculus.Carrier.zero →
            x =
              PropertyKindCalculus.Carrier.zero)
      (w : P → E)
      (d :
        PropertyKindCalculus.Decomposition
          P) :
      PropertyKindCalculus.totalWeight w d ≠
          PropertyKindCalculus.Carrier.zero ↔
        PropertyKindCalculus.totalWeight
            (fun p =>
              PropertyKindCalculus.CarrierRefinement.toSpec
                (w p))
            d ≠
          PropertyKindCalculus.Carrier.zero
    **So a non-rounding carrier has one license, not two.** The executable carving's own field and
    the specification's precondition are then the same statement read through `toSpec`, and a run-time
    test of the computed total *is* a test of the quantity being defined. This is why a mean whose
    denominator is a count should fold that count in an exact carrier and convert once, rather than
    accumulate it in the same floating-point type as the numerator.
    
    The second hypothesis is that `toSpec` reflects zero — it sends only the exec zero to the spec
    zero. Every refinement in this library has it; it is stated rather than assumed because a lossy
    `toSpec` that collapsed a subnormal to zero would not. 
Proof for Theorem 15.6.5
uses 0

By induction on the carving: identity rounding makes the bridge law an additive homomorphism, so the fold commutes with the forgetting. Stated in the core, over an arbitrary refinement, since nothing about binary32 enters.

This is the strongest of the two remedies and the one to reach for first, because it removes the question rather than answering it. It is available exactly when the weights are counts or indicators — a validity mask, a sample tally, a pixel count — which is the ordinary shape of a masked average: fold the denominator where addition is exact and convert to the numerator's carrier once, rather than accumulating it in the same floating-point type as the numerator.

Theorem15.6.6
Group: Mass is extensive: the mass of a whole is the sum of the masses of its parts. Volume on mixing is not: ethanol and water mix sub-additively. Tracking which kinds are extensive is a precondition for soundly aggregating measurements. (30)
Group member previews
Preview
Definition 15.1.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 2
Reverse dependency previews
Preview
Definition 17.3.1
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

Nonnegative weights make the two licenses equivalent. Where the denominator genuinely is a binary32 fold of real-valued weights, requiring them to be nonnegative and on the grid restores the equivalence: the rounded total is zero exactly when the exact total is. Uses weighted carvings.

Lean code for Theorem15.6.6●1 theorem
  • theoremdefined in PropertyKindCalculus/Uncertainty/Adequacy/MeanBound.lean
    complete
    theorem PropertyKindCalculus.Uncertainty.Adequacy.licenses_agree_of_nonneg.{u}
      {P : Type u} (w : P → TorchLean.Floats.FP32)
      (hnn : ∀ (p : P), 0 ≤ (w p).val)
      (hg :
        ∀ (p : P), FloatLib.Floats.Formats.Flocq.NF.IsRepresentable (w p))
      (d : PropertyKindCalculus.Decomposition P) :
      (PropertyKindCalculus.totalWeight w d).val ≠ 0 ↔
        PropertyKindCalculus.totalWeight (fun p => (w p).val) d ≠ 0
    theorem PropertyKindCalculus.Uncertainty.Adequacy.licenses_agree_of_nonneg.{u}
      {P : Type u}
      (w : P → TorchLean.Floats.FP32)
      (hnn : ∀ (p : P), 0 ≤ (w p).val)
      (hg :
        ∀ (p : P),
          FloatLib.Floats.Formats.Flocq.NF.IsRepresentable
            (w p))
      (d :
        PropertyKindCalculus.Decomposition
          P) :
      (PropertyKindCalculus.totalWeight w
              d).val ≠
          0 ↔
        PropertyKindCalculus.totalWeight
            (fun p => (w p).val) d ≠
          0
    **The two licenses coincide on nonnegative grid weights.** So for masses, areas, durations,
    coverage fractions and validity indicators, a `WeightedCarving FP32`'s own field *is* the
    specification's precondition, and nothing further need be established.
    
    Both hypotheses are needed and neither is idle. Nonnegativity rules out the cancellation both
    counterexamples are built from. Grid membership is not automatic: `NF` is a bare record over `ℝ`
    with representability a separate predicate, so "this is a binary32 number" has to be said — and
    without it a weight below half the smallest subnormal would round away and the argument would
    fail at exactly the leaf it starts from. 
Proof for Theorem 15.6.6
uses 0

Both counterexamples are built from cancellation, so nonnegativity is exactly what excludes them. The floating-point content is one lemma — a grid point does not shrink when a nonnegative is added to it and the sum is rounded, which is monotonicity of rounding together with rounding fixing the grid. Absorption may return the grid point unchanged; it cannot return anything smaller. Induction then gives both halves: a positive exact total forces a positive rounded one, and a zero exact total forces a zero rounded one.

Grid membership is a real hypothesis, not bookkeeping: the rounding-spec format is a bare record over \mathbb{R} with representability a separate predicate, so "this is a binary32 number" has to be said, and without it a weight below half the smallest subnormal would round away and the argument would fail at the leaf it starts from.

This covers the weights metrology actually uses — masses, areas, durations, coverage fractions, validity indicators — but it is the second-best fix. Where the weights are counts, the theorem above applies and no floating-point reasoning is needed at all.

Definition15.6.7
Group: Mass is extensive: the mass of a whole is the sum of the masses of its parts. Volume on mixing is not: ethanol and water mix sub-additively. Tracking which kinds are extensive is a precondition for soundly aggregating measurements. (30)
Group member previews
Preview
Definition 15.1.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1used by 0✓L∃∀N

The mode with its kinds on. A weighted carving over a bare carrier is silent about three things a kind layer can say. The weight kind has to be one that sums, so WeightedCarvingQ carries its carving's difference-kind proof as a field and a carving of a non-summable kind cannot be built. The weight, value and product kinds have to be related, so the mean asks for a product license and a quotient license that say so. And the quotient the mean performs is a licensed kind change, not a bare division.

Lean code for Definition15.6.7●1 definition
  • structure(4 fields)defined in PropertyKindCalculus/Aggregation.lean
    complete
    structure PropertyKindCalculus.WeightedCarvingQ.{u} (R : Type)
      [PropertyKindCalculus.Carrier R]
      (kw : PropertyKindCalculus.KindOfProperty) (P : Type u) : Type u
    structure PropertyKindCalculus.WeightedCarvingQ.{u}
      (R : Type)
      [PropertyKindCalculus.Carrier R]
      (kw :
        PropertyKindCalculus.KindOfProperty)
      (P : Type u) : Type u
    **A carving whose weights are quantities of a summable kind, with a nonzero total.** The
    `differenceKind` field is the permission to fold at all; `total_ne_zero` is the license to divide,
    stated on the magnitude because that is where division can fail. 
    parts : PropertyKindCalculus.Decomposition P
    The carving of the whole into parts. 
    weight : P → PropertyKindCalculus.Quantity kw R
    The weight borne by each part. 
    differenceKind : PropertyKindCalculus.DifferenceKind kw
    The weight kind admits differences, so the weights may be summed. 
    total_ne_zero : (PropertyKindCalculus.totalWeightQ ⋯ self.weight self.parts).magnitude ≠ PropertyKindCalculus.Carrier.zero
    The total weight is nonzero — the mean's denominator is licensed. 
Theorem15.6.8
Group: Mass is extensive: the mass of a whole is the sum of the masses of its parts. Volume on mixing is not: ethanol and water mix sub-additively. Tracking which kinds are extensive is a precondition for soundly aggregating measurements. (30)
Group member previews
Preview
Definition 15.1.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1used by 0✓L∃∀N

The kinded mean computes what the carrier mean computes. Its magnitude is the carrier-level mean of the same data. So the kind index gates which folds may be written and contributes nothing to the value — which is what lets the binary32 bound, stated about magnitudes, apply unchanged to a mean a user wrote with kinds on.

Lean code for Theorem15.6.8●1 theorem
  • theoremdefined in PropertyKindCalculus/Aggregation.lean
    complete
    theorem PropertyKindCalculus.WeightedCarvingQ.mean_magnitude.{u} {R : Type}
      {P : Type u} [PropertyKindCalculus.Carrier R] [Mul R] [Div R]
      [PropertyKindCalculus.ScalarCarrier R]
      {kw kv kwv : PropertyKindCalculus.KindOfProperty}
      (c : PropertyKindCalculus.WeightedCarvingQ R kw P)
      (hp : PropertyKindCalculus.ProductKind kw kv kwv)
      (hq : PropertyKindCalculus.QuotientKind kwv kw kv)
      (hd : PropertyKindCalculus.DifferenceKind kwv)
      (v : P → PropertyKindCalculus.Quantity kv R) :
      (c.mean hp hq hd v).magnitude =
        c.toCarving.mean fun p => (v p).magnitude
    theorem PropertyKindCalculus.WeightedCarvingQ.mean_magnitude.{u}
      {R : Type} {P : Type u}
      [PropertyKindCalculus.Carrier R] [Mul R]
      [Div R]
      [PropertyKindCalculus.ScalarCarrier R]
      {kw kv kwv :
        PropertyKindCalculus.KindOfProperty}
      (c :
        PropertyKindCalculus.WeightedCarvingQ
          R kw P)
      (hp :
        PropertyKindCalculus.ProductKind kw kv
          kwv)
      (hq :
        PropertyKindCalculus.QuotientKind kwv
          kw kv)
      (hd :
        PropertyKindCalculus.DifferenceKind
          kwv)
      (v :
        P →
          PropertyKindCalculus.Quantity kv
            R) :
      (c.mean hp hq hd v).magnitude =
        c.toCarving.mean fun p =>
          (v p).magnitude
    **The kinded mean erases to the carrier mean.** This is the bridge that lets the binary32 bound
    of `Uncertainty.Adequacy.MeanBound`, which is stated about magnitudes, apply to a mean a user wrote
    with kinds on. 
Proof for Theorem 15.6.8
uses 0

Two inductions over the carving, one per fold, each with the same shape: a leaf is the erasure by definition, and a join is Carrier.add on both sides once the operands have been rewritten. Realized in the Mathlib-free core (Aggregation.lean), depending on propext alone.

The theorem is what makes the kinded layer honest about its cost. Nothing is recomputed and no numerical claim is restated: the three obligations above are discharged once at construction, and everything proved downstream about magnitudes continues to hold.

Theorem15.6.9
Group: Mass is extensive: the mass of a whole is the sum of the masses of its parts. Volume on mixing is not: ethanol and water mix sub-additively. Tracking which kinds are extensive is a precondition for soundly aggregating measurements. (30)
Group member previews
Preview
Definition 15.1.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 0used by 0✓L∃∀N

The mean's division is an R10 site. Forgetting the executable kinded mean to the specification carrier is the rounding of the specification quotient of the forgotten numerator and denominator — the quotient bridge read at the mean's own division node.

Lean code for Theorem15.6.9●1 theorem
  • theoremdefined in PropertyKindCalculus/Aggregation.lean
    complete
    theorem PropertyKindCalculus.WeightedCarvingQ.mean_div_refines.{u} {E S : Type}
      {P : Type u} [PropertyKindCalculus.Carrier E]
      [PropertyKindCalculus.Carrier S] [Mul E] [Mul S] [Div E] [Div S]
      [PropertyKindCalculus.ScalarCarrier E]
      [PropertyKindCalculus.ScalarCarrier S]
      [PropertyKindCalculus.CarrierRefinement E S]
      [PropertyKindCalculus.DivRefinement E S]
      {kw kv kwv : PropertyKindCalculus.KindOfProperty}
      (c : PropertyKindCalculus.WeightedCarvingQ E kw P)
      (hp : PropertyKindCalculus.ProductKind kw kv kwv)
      (hq : PropertyKindCalculus.QuotientKind kwv kw kv)
      (hd : PropertyKindCalculus.DifferenceKind kwv)
      (v : P → PropertyKindCalculus.Quantity kv E) :
      (c.mean hp hq hd v).toSpec =
        PropertyKindCalculus.Quantity.roundBy
          (PropertyKindCalculus.CarrierRefinement.round E)
          (PropertyKindCalculus.Quantity.div hq
            (PropertyKindCalculus.weightedSumQ hp hd c.weight v
                c.parts).toSpec
            c.total.toSpec)
    theorem PropertyKindCalculus.WeightedCarvingQ.mean_div_refines.{u}
      {E S : Type} {P : Type u}
      [PropertyKindCalculus.Carrier E]
      [PropertyKindCalculus.Carrier S] [Mul E]
      [Mul S] [Div E] [Div S]
      [PropertyKindCalculus.ScalarCarrier E]
      [PropertyKindCalculus.ScalarCarrier S]
      [PropertyKindCalculus.CarrierRefinement
          E S]
      [PropertyKindCalculus.DivRefinement E S]
      {kw kv kwv :
        PropertyKindCalculus.KindOfProperty}
      (c :
        PropertyKindCalculus.WeightedCarvingQ
          E kw P)
      (hp :
        PropertyKindCalculus.ProductKind kw kv
          kwv)
      (hq :
        PropertyKindCalculus.QuotientKind kwv
          kw kv)
      (hd :
        PropertyKindCalculus.DifferenceKind
          kwv)
      (v :
        P →
          PropertyKindCalculus.Quantity kv
            E) :
      (c.mean hp hq hd v).toSpec =
        PropertyKindCalculus.Quantity.roundBy
          (PropertyKindCalculus.CarrierRefinement.round
            E)
          (PropertyKindCalculus.Quantity.div
            hq
            (PropertyKindCalculus.weightedSumQ
                hp hd c.weight v
                c.parts).toSpec
            c.total.toSpec)
    **The mean's quotient refines (R10).** Forgetting the executable mean to the spec carrier is the
    rounding of the spec quotient of the forgotten numerator and denominator — `Quantity.div_refines` at
    the mean's own division node. 
Proof for Theorem 15.6.9

Immediate from the quotient bridge, and that is the point: until the mean acquired kinds, the bridge had no consumer that was not a test of itself. A weighted mean is the first model-level construct in the library that divides across a licensed kind change, so it is the first place the law does work.

What the theorem does not say is that the whole mean commutes with the forgetful map. The folds above the division round at every join, and pushing the forgetful map through them is exactly what the exact-carrier hypothesis supplies. The division is one step of that argument, stated where it holds with no side condition. Instantiated at the binary32 rung on an indicator-weighted carving whose license is discharged rather than assumed.