Reference · Signed rationals
rainbow.math.rational.signed.list-sum
Finite sums of signed rationals over a list, and their order laws. signed/map-sum A f xs = f x0 + f x1 + ... + f xn (empty sum = 0) signed/map-sum-monotone : (forall x, f x <= g x) -> sum f xs <= sum g xs signed/map-sum-nonpositive : (forall x, f x <= 0) -> sum f xs <= 0 signed/map-sum-nonnegative : (forall x, 0 <= f x) -> 0 <= sum f xs The nnrat side already had `nnrat/map-sum`; the signed side had nothing, so every aggregate over signed quantities -- a Lagrangian penalty, a dot product, a total reward with sign -- had to stay abstract. These are the same List.rec folds: nil is order-reflexivity at `signed/zero`, cons is `signed/add-monotone` against the induction hypothesis, and the two sign versions additionally collapse the `0 + 0` produced in the cons step with `signed/add-zero-right`. Polymorphic in the index type. Native and axiom-free; chains signed order monotonicity and signed limit uniqueness (for signed/add-zero-right) on D63.
signed/map-sum
signed/map-sum.{u} :
(A : Type u) (f : A → ℚ) (x₁ : List A)
→ ℚList = data/Listℚ = signed/SignedRational
signed/map-sum-empty
signed/map-sum-empty.{u} :
(A : Type u) (f : A → ℚ)
→ Σ j∈[], f j = 00 = signed/zero= = equality/EqΣ = signed/map-sum: sum over the listed indicesℚ = signed/SignedRational
signed/map-sum-cons
signed/map-sum-cons.{u} :
(A : Type u) (f : A → ℚ) (head : A) (tail : List A)
→ Σ j∈data/cons A head tail, f j = f head + Σ j∈tail, f j+ = signed/add= = equality/EqList = data/ListΣ = signed/map-sum: sum over the listed indicesℚ = signed/SignedRational
signed/map-sum-monotone
signed/map-sum-monotone.{u} :
(A : Type u) (f g : A → ℚ)
(hfg : ∀ (x : A), f x ≤ g x)
(xs : List A)
→ Σ j∈xs, f j ≤ Σ j∈xs, g jList = data/ListΣ = signed/map-sum: sum over the listed indicesℚ = signed/SignedRational≤ = signed/at-most
signed/map-sum-nonpositive
signed/map-sum-nonpositive.{u} :
(A : Type u) (f : A → ℚ)
(hf : ∀ (x : A), f x ≤ 0)
(xs : List A)
→ Σ j∈xs, f j ≤ 00 = signed/zeroList = data/ListΣ = signed/map-sum: sum over the listed indicesℚ = signed/SignedRational≤ = signed/at-most
signed/map-sum-nonnegative
signed/map-sum-nonnegative.{u} :
(A : Type u) (f : A → ℚ)
(hf : ∀ (x : A), 0 ≤ f x)
(xs : List A)
→ 0 ≤ Σ j∈xs, f j0 = signed/zeroList = data/ListΣ = signed/map-sum: sum over the listed indicesℚ = signed/SignedRational≤ = signed/at-most