Documentation

ConvexAnalysis.BallArithmetic

Ball arithmetic #

Ball arithmetic (midpoint–radius arithmetic) encloses an unknown element x of a normed ring R in a ball ⟨c, r⟩, a center c : R and a radius r ≥ 0 that stand for closedBall c r. The operations on balls have the inclusion property: if x ∈ B₁ and y ∈ B₂, then x + y ∈ B₁ + B₂, x * y ∈ B₁ * B₂, and so on. Hence evaluating an expression in balls gives a ball that contains the value of the expression at every point of the input balls. This is the arithmetic of Arb Johansson, Arb and of van der Hoeven's Ball arithmetic; on ℝ it is Rump's midpoint–radius interval arithmetic Rump, Fast and parallel interval arithmetic. The theorems that turn enclosures into existence proofs are in ConvexAnalysis.RadiiPolynomial.

Main definitions #

Main statements #

Implementation notes #

References #

Tags #

ball arithmetic, midpoint–radius arithmetic, interval arithmetic, inclusion property, inclusion isotonicity, rigorous numerics, validated numerics

structure ConvexAnalysis.Ball (R : Type u_1) :
Type u_1

A ball in R: a center c and a radius r ≥ 0, standing for the closed ball closedBall c r (ConvexAnalysis.Ball.toSet).

  • center : R

    The center (midpoint) of the ball.

  • radius : NNReal

    The radius of the ball.

Instances For
    theorem ConvexAnalysis.Ball.ext_iff {R : Type u_1} {x y : Ball R} :

    Two balls are equal iff their centers and their radii are equal.

    theorem ConvexAnalysis.Ball.ext {R : Type u_1} {x y : Ball R} (center : x.center = y.center) (radius : x.radius = y.radius) :
    x = y

    Two balls are equal if their centers and their radii are equal.

    The set that a ball stands for, closedBall B.center B.radius.

    Equations
    Instances For
      @[instance_reducible]

      Balls are enclosures in the sense of Mathlib's inclusion tactic. This instance gives the membership x ∈ B, which means x ∈ B.toSet.

      Equations
      theorem ConvexAnalysis.Ball.mem_iff_mem_toSet {R : Type u_1} [SeminormedAddCommGroup R] {B : Ball R} {x : R} :
      x ∈ B ↔ x ∈ B.toSet

      Membership in a ball is membership in its set.

      @[simp]
      theorem ConvexAnalysis.Ball.mem_iff {R : Type u_1} [SeminormedAddCommGroup R] {B : Ball R} {x : R} :

      x ∈ B iff ‖x - c‖ ≤ r.

      The center lies in the ball.

      @[instance_reducible]

      The ball order of van der Hoeven: B ≤ B' if ‖B.center - B'.center‖ + B.radius ≤ B'.radius. It implies B.toSet ⊆ B'.toSet (ConvexAnalysis.Ball.toSet_mono).

      Equations
      theorem ConvexAnalysis.Ball.le_def {R : Type u_1} [SeminormedAddCommGroup R] {B B' : Ball R} :
      B ≤ B' ↔ ‖B.center - B'.center‖ + ↑B.radius ≤ ↑B'.radius

      The definition of the ball order.

      theorem ConvexAnalysis.Ball.le_of_center_eq {R : Type u_1} [SeminormedAddCommGroup R] {B B' : Ball R} (hc : B.center = B'.center) (hr : B.radius ≤ B'.radius) :
      B ≤ B'

      A ball with the same center and a bigger radius is bigger.

      theorem ConvexAnalysis.Ball.toSet_mono {R : Type u_1} [SeminormedAddCommGroup R] {B B' : Ball R} (h : B ≤ B') :
      B.toSet ⊆ B'.toSet

      The ball order implies inclusion of the sets.

      theorem ConvexAnalysis.Ball.mem_of_le {R : Type u_1} [SeminormedAddCommGroup R] {B B' : Ball R} {x : R} (hx : x ∈ B) (h : B ≤ B') :
      x ∈ B'

      A bigger ball contains every element of a smaller one.

      theorem ConvexAnalysis.Ball.le_mk {R : Type u_1} [SeminormedAddCommGroup R] {c c' : R} {r r' : NNReal} {δ : ℝ} (hc : ‖c - c'‖ ≤ δ) (hr : ↑r + δ ≤ ↑r') :
      { center := c, radius := r } ≤ { center := c', radius := r' }

      Rounding: replacing the center c by c' with ‖c - c'‖ ≤ δ and the radius r by r' ≥ r + δ gives a bigger ball. This is how a floating-point implementation of an operation returns an enclosure of the exact result.

      def ConvexAnalysis.Ball.enlarge {R : Type u_1} (B : Ball R) (ε : NNReal) :

      The ball B with its radius enlarged by ε.

      Equations
      Instances For
        theorem ConvexAnalysis.Ball.le_enlarge {R : Type u_1} [SeminormedAddCommGroup R] (B : Ball R) (ε : NNReal) :
        B ≤ B.enlarge ε

        Enlarging the radius keeps a valid enclosure.

        def ConvexAnalysis.Ball.point {R : Type u_1} (c : R) :

        The ball ⟨c, 0⟩ that stands for the point c (in a normed group).

        Equations
        Instances For

          c lies in the point ball ⟨c, 0⟩.

          Addition, negation, subtraction #

          @[instance_reducible]

          The ball sum: center c₁ + c₂ and radius r₁ + r₂.

          Equations
          @[simp]
          theorem ConvexAnalysis.Ball.center_add {R : Type u_1} [SeminormedAddCommGroup R] {B₁ B₂ : Ball R} :
          (B₁ + B₂).center = B₁.center + B₂.center

          The center of a ball sum.

          @[simp]
          theorem ConvexAnalysis.Ball.radius_add {R : Type u_1} [SeminormedAddCommGroup R] {B₁ B₂ : Ball R} :
          (B₁ + B₂).radius = B₁.radius + B₂.radius

          The radius of a ball sum.

          theorem ConvexAnalysis.Ball.add_mem_add {R : Type u_1} [SeminormedAddCommGroup R] {B₁ B₂ : Ball R} {x y : R} (hx : x ∈ B₁) (hy : y ∈ B₂) :
          x + y ∈ B₁ + B₂

          Inclusion property of ball addition.

          theorem ConvexAnalysis.Ball.add_mono {R : Type u_1} [SeminormedAddCommGroup R] {B₁ B₂ B₁' B₂' : Ball R} (h₁ : B₁ ≤ B₁') (h₂ : B₂ ≤ B₂') :
          B₁ + B₂ ≤ B₁' + B₂'

          Inclusion isotonicity of ball addition.

          @[instance_reducible]

          The ball negation: center -c and radius r.

          Equations
          @[simp]

          The center of a ball negation.

          @[simp]

          The radius of a ball negation.

          theorem ConvexAnalysis.Ball.neg_mem_neg {R : Type u_1} [SeminormedAddCommGroup R] {B : Ball R} {x : R} (hx : x ∈ B) :
          -x ∈ -B

          Inclusion property of ball negation.

          theorem ConvexAnalysis.Ball.neg_mono {R : Type u_1} [SeminormedAddCommGroup R] {B B' : Ball R} (h : B ≤ B') :
          -B ≤ -B'

          Inclusion isotonicity of ball negation.

          @[instance_reducible]

          The ball difference: center c₁ - c₂ and radius r₁ + r₂.

          Equations
          @[simp]
          theorem ConvexAnalysis.Ball.center_sub {R : Type u_1} [SeminormedAddCommGroup R] {B₁ B₂ : Ball R} :
          (B₁ - B₂).center = B₁.center - B₂.center

          The center of a ball difference.

          @[simp]
          theorem ConvexAnalysis.Ball.radius_sub {R : Type u_1} [SeminormedAddCommGroup R] {B₁ B₂ : Ball R} :
          (B₁ - B₂).radius = B₁.radius + B₂.radius

          The radius of a ball difference.

          theorem ConvexAnalysis.Ball.sub_eq_add_neg {R : Type u_1} [SeminormedAddCommGroup R] (B₁ B₂ : Ball R) :
          B₁ - B₂ = B₁ + -B₂

          Ball subtraction is the sum with the negation.

          theorem ConvexAnalysis.Ball.sub_mem_sub {R : Type u_1} [SeminormedAddCommGroup R] {B₁ B₂ : Ball R} {x y : R} (hx : x ∈ B₁) (hy : y ∈ B₂) :
          x - y ∈ B₁ - B₂

          Inclusion property of ball subtraction.

          theorem ConvexAnalysis.Ball.sub_mono {R : Type u_1} [SeminormedAddCommGroup R] {B₁ B₂ B₁' B₂' : Ball R} (h₁ : B₁ ≤ B₁') (h₂ : B₂ ≤ B₂') :
          B₁ - B₂ ≤ B₁' - B₂'

          Inclusion isotonicity of ball subtraction.

          Scalar multiples #

          @[instance_reducible]
          instance ConvexAnalysis.Ball.instSMul {R : Type u_1} [SeminormedAddCommGroup R] {𝕜 : Type u_2} [SeminormedRing 𝕜] [Module 𝕜 R] :
          SMul 𝕜 (Ball R)

          The scalar multiple: center a • c and radius ‖a‖ r.

          Equations
          @[simp]
          theorem ConvexAnalysis.Ball.center_smul {R : Type u_1} [SeminormedAddCommGroup R] {B : Ball R} {𝕜 : Type u_2} [SeminormedRing 𝕜] [Module 𝕜 R] (a : 𝕜) :
          (a • B).center = a • B.center

          The center of a scalar multiple.

          @[simp]
          theorem ConvexAnalysis.Ball.radius_smul {R : Type u_1} [SeminormedAddCommGroup R] {B : Ball R} {𝕜 : Type u_2} [SeminormedRing 𝕜] [Module 𝕜 R] (a : 𝕜) :

          The radius of a scalar multiple.

          theorem ConvexAnalysis.Ball.smul_mem_smul {R : Type u_1} [SeminormedAddCommGroup R] {B : Ball R} {x : R} {𝕜 : Type u_2} [SeminormedRing 𝕜] [Module 𝕜 R] [IsBoundedSMul 𝕜 R] (a : 𝕜) (hx : x ∈ B) :
          a • x ∈ a • B

          Inclusion property of scalar multiples.

          theorem ConvexAnalysis.Ball.smul_mono {R : Type u_1} [SeminormedAddCommGroup R] {B B' : Ball R} {𝕜 : Type u_2} [SeminormedRing 𝕜] [Module 𝕜 R] [IsBoundedSMul 𝕜 R] (a : 𝕜) (h : B ≤ B') :
          a • B ≤ a • B'

          Inclusion isotonicity of scalar multiples.

          @[instance_reducible]

          In a normed group the ball order is a partial order: B ≤ B' and B' ≤ B give 2 ‖c - c'‖ ≤ 0, so the centers and then the radii agree.

          Equations

          The ball order and inclusion of sets #

          theorem ConvexAnalysis.Ball.le_iff_toSet_subset {R : Type u_1} [NormedAddCommGroup R] [NormedSpace ℝ R] {B : Ball R} [Nontrivial R] {B' : Ball R} :
          B ≤ B' ↔ B.toSet ⊆ B'.toSet

          In a nontrivial real normed space, the ball order is inclusion of the sets: if closedBall c r ⊆ closedBall c' r' with r ≥ 0, the point c + r u, for the unit vector u in the direction c - c', gives ‖c - c'‖ + r ≤ r'.

          theorem ConvexAnalysis.Ball.toSet_add {R : Type u_1} [NormedAddCommGroup R] [NormedSpace ℝ R] (B₁ B₂ : Ball R) :
          (B₁ + B₂).toSet = B₁.toSet + B₂.toSet

          In a real normed space, ball addition is exact: the set of B₁ + B₂ is the Minkowski sum of the sets of B₁ and B₂.

          Multiplication and powers #

          @[instance_reducible]

          The ball product: center c₁ c₂ and radius ‖c₁‖ r₂ + ‖c₂‖ r₁ + r₁ r₂.

          Equations
          • One or more equations did not get rendered due to their size.
          @[simp]
          theorem ConvexAnalysis.Ball.center_mul {R : Type u_1} [NonUnitalSeminormedRing R] {B₁ B₂ : Ball R} :
          (B₁ * B₂).center = B₁.center * B₂.center

          The center of a ball product.

          @[simp]
          theorem ConvexAnalysis.Ball.radius_mul {R : Type u_1} [NonUnitalSeminormedRing R] {B₁ B₂ : Ball R} :
          (B₁ * B₂).radius = ‖B₁.center‖₊ * B₂.radius + ‖B₂.center‖₊ * B₁.radius + B₁.radius * B₂.radius

          The radius of a ball product.

          theorem ConvexAnalysis.Ball.coe_radius_mul {R : Type u_1} [NonUnitalSeminormedRing R] {B₁ B₂ : Ball R} :
          ↑(B₁ * B₂).radius = ‖B₁.center‖ * ↑B₂.radius + ‖B₂.center‖ * ↑B₁.radius + ↑B₁.radius * ↑B₂.radius

          The radius of a ball product, in ℝ.

          theorem ConvexAnalysis.Ball.mul_mem_mul {R : Type u_1} [NonUnitalSeminormedRing R] {B₁ B₂ : Ball R} {x y : R} (hx : x ∈ B₁) (hy : y ∈ B₂) :
          x * y ∈ B₁ * B₂

          Inclusion property of the ball product.

          theorem ConvexAnalysis.Ball.mul_mono {R : Type u_1} [NonUnitalSeminormedRing R] {B₁ B₂ B₁' B₂' : Ball R} (h₁ : B₁ ≤ B₁') (h₂ : B₂ ≤ B₂') :
          B₁ * B₂ ≤ B₁' * B₂'

          Inclusion isotonicity of the ball product.

          theorem ConvexAnalysis.Ball.norm_pow_sub_pow_le {R : Type u_1} [SeminormedRing R] {x c : R} {r : ℝ} (hx : ‖x - c‖ ≤ r) (n : ℕ) :
          ‖x ^ n - c ^ n‖ ≤ (‖c‖ + r) ^ n - ‖c‖ ^ n

          The power bound in a normed ring: ‖x ^ n - c ^ n‖ ≤ (‖c‖ + r) ^ n - ‖c‖ ^ n for ‖x - c‖ ≤ r. It needs neither commutativity nor ‖1‖ = 1.

          @[instance_reducible]

          The ball power: center c ^ n and radius (‖c‖ + r) ^ n - ‖c‖ ^ n.

          Equations
          @[simp]
          theorem ConvexAnalysis.Ball.center_pow {R : Type u_1} [SeminormedRing R] {B : Ball R} (n : ℕ) :
          (B ^ n).center = B.center ^ n

          The center of a ball power.

          @[simp]
          theorem ConvexAnalysis.Ball.radius_pow {R : Type u_1} [SeminormedRing R] {B : Ball R} (n : ℕ) :

          The radius of a ball power.

          theorem ConvexAnalysis.Ball.coe_radius_pow {R : Type u_1} [SeminormedRing R] {B : Ball R} (n : ℕ) :
          ↑(B ^ n).radius = (‖B.center‖ + ↑B.radius) ^ n - ‖B.center‖ ^ n

          The radius of a ball power, in ℝ.

          theorem ConvexAnalysis.Ball.pow_mem_pow {R : Type u_1} [SeminormedRing R] {B : Ball R} {x : R} (hx : x ∈ B) (n : ℕ) :
          x ^ n ∈ B ^ n

          Inclusion property of the ball power.

          theorem ConvexAnalysis.Ball.pow_mono {R : Type u_1} [SeminormedRing R] {B B' : Ball R} (h : B ≤ B') (n : ℕ) :
          B ^ n ≤ B' ^ n

          Inclusion isotonicity of the ball power.

          Polynomials: Horner's scheme #

          def ConvexAnalysis.Ball.horner {R : Type u_1} [SeminormedRing R] (X : Ball R) :
          (ℕ → Ball R) → ℕ → Ball R

          Horner's scheme in ball arithmetic: horner X A n = A 0 + (A 1 + (⋯ + A n * X) ⋯ * X) * X evaluates the polynomial with ball coefficients A 0, …, A n at the ball X. The multiplication by X is on the right, as in ∑ aᵢ xⁱ.

          Equations
          Instances For
            @[simp]
            theorem ConvexAnalysis.Ball.horner_zero {R : Type u_1} [SeminormedRing R] (X : Ball R) (A : ℕ → Ball R) :
            X.horner A 0 = A 0

            Horner's scheme for a constant.

            theorem ConvexAnalysis.Ball.horner_succ {R : Type u_1} [SeminormedRing R] (X : Ball R) (A : ℕ → Ball R) (n : ℕ) :
            X.horner A (n + 1) = A 0 + X.horner (fun (i : ℕ) => A (i + 1)) n * X

            One step of Horner's scheme.

            theorem ConvexAnalysis.Ball.sum_mem_horner {R : Type u_1} [SeminormedRing R] {x : R} {X : Ball R} (hx : x ∈ X) {a : ℕ → R} {A : ℕ → Ball R} {n : ℕ} (ha : ∀ i ≤ n, a i ∈ A i) :
            ∑ i ∈ Finset.range (n + 1), a i * x ^ i ∈ X.horner A n

            Inclusion property of Horner's scheme: if aᵢ ∈ A i for i ≤ n and x ∈ X, then ∑_{i ≤ n} aᵢ xⁱ ∈ horner X A n.

            theorem ConvexAnalysis.Ball.horner_mono {R : Type u_1} [SeminormedRing R] {X X' : Ball R} (hX : X ≤ X') {A A' : ℕ → Ball R} {n : ℕ} (hA : ∀ i ≤ n, A i ≤ A' i) :
            X.horner A n ≤ X'.horner A' n

            Inclusion isotonicity of Horner's scheme.

            theorem ConvexAnalysis.Ball.eval_mem_horner {R : Type u_1} [SeminormedRing R] {x : R} (p : Polynomial R) {X : Ball R} (hx : x ∈ X) :
            Polynomial.eval x p ∈ X.horner (fun (i : ℕ) => point (p.coeff i)) p.natDegree

            Polynomial evaluation in balls: p.eval x lies in the ball computed by Horner's scheme from the exact coefficients of p, for every x ∈ X.

            Inverse #

            @[instance_reducible]
            noncomputable instance ConvexAnalysis.Ball.instInv {R : Type u_1} [NormedRing R] :
            Inv (Ball R)

            The ball inverse: center c⁻¹ (Ring.inverse c) and radius ‖c⁻¹‖² r / (1 - ‖c⁻¹‖ r). It is an enclosure of the inverses if c is a unit and ‖c⁻¹‖ r < 1 (ConvexAnalysis.Ball.inverse_mem_inv). If ‖c⁻¹‖ r ≥ 1, the truncated subtraction of ℝ≥0 gives the denominator 0 and the radius 0: then B⁻¹ is the point c⁻¹ and no enclosure (the ball may contain 0).

            Equations
            • One or more equations did not get rendered due to their size.
            @[simp]

            The center of a ball inverse.

            The radius of a ball inverse, in ℝ, when ‖c⁻¹‖ r < 1.

            theorem ConvexAnalysis.Ball.isUnit_of_mem {R : Type u_1} [NormedRing R] {B : Ball R} {x : R} [HasSummableGeomSeries R] (hc : IsUnit B.center) (hB : ‖Ring.inverse B.center‖ * ↑B.radius < 1) (hx : x ∈ B) :

            If the center c of B is a unit and ‖c⁻¹‖ r < 1, every element of B is a unit.

            theorem ConvexAnalysis.Ball.inverse_mem_inv {R : Type u_1} [NormedRing R] {B : Ball R} {x : R} [HasSummableGeomSeries R] (hc : IsUnit B.center) (hB : ‖Ring.inverse B.center‖ * ↑B.radius < 1) (hx : x ∈ B) :

            Inclusion property of the ball inverse in a complete normed ring: if the center c is a unit and ‖c⁻¹‖ r < 1, then the inverse of every element of B lies in B⁻¹, the ball around c⁻¹ of radius ‖c⁻¹‖² r / (1 - ‖c⁻¹‖ r). The proof uses x⁻¹ - c⁻¹ = x⁻¹ (c - x) c⁻¹.

            theorem ConvexAnalysis.Ball.inv_mono {R : Type u_1} [NormedRing R] {B : Ball R} [HasSummableGeomSeries R] {B' : Ball R} (h : B ≤ B') (hc : IsUnit B'.center) (hB : ‖Ring.inverse B'.center‖ * ↑B'.radius < 1) :

            Inclusion isotonicity of the ball inverse: if B ≤ B' and B' satisfies the hypotheses of ConvexAnalysis.Ball.inverse_mem_inv, then so does B, and B⁻¹ ≤ B'⁻¹. With s = ‖c'⁻¹‖, d = ‖c - c'‖, the proof bounds ‖c⁻¹ - c'⁻¹‖ by s² d / (1 - s d) and ‖c⁻¹‖ by s / (1 - s d), and uses s² d / (1 - s d) + s² r / ((1 - s d) (1 - s d - s r)) = s² (d + r) / (1 - s (d + r)).

            theorem ConvexAnalysis.Ball.inv_mem_inv {K : Type u_2} [NormedDivisionRing K] [HasSummableGeomSeries K] {B : Ball K} {x : K} (hc : B.center ≠ 0) (hB : ‖B.center⁻¹‖ * ↑B.radius < 1) (hx : x ∈ B) :

            Inclusion property of the ball inverse in a normed division ring: if c ≠ 0 and ‖c⁻¹‖ r < 1, then x⁻¹ ∈ B⁻¹ for every x ∈ B, and x ≠ 0.

            Balls and intervals in ℝ #

            In ℝ, the ball ⟨c, r⟩ is the interval [c - r, c + r].

            theorem ConvexAnalysis.Ball.mem_iff_mem_Icc {B : Ball ℝ} {x : ℝ} :
            x ∈ B ↔ x ∈ Set.Icc (B.center - ↑B.radius) (B.center + ↑B.radius)

            In ℝ, x ∈ B iff c - r ≤ x ≤ c + r.

            noncomputable def ConvexAnalysis.Ball.ofIcc (a b : ℝ) :

            The ball ⟨(a + b) / 2, (b - a) / 2⟩ with the midpoint and the radius of [a, b].

            Equations
            Instances For
              theorem ConvexAnalysis.Ball.toSet_ofIcc {a b : ℝ} (hab : a ≤ b) :
              (ofIcc a b).toSet = Set.Icc a b

              The ball of an interval [a, b] with a ≤ b is the interval.

              The interval [c - r, c + r] of a ball ⟨c, r⟩ in ℝ.

              Equations
              Instances For

                The ball ⟨(a + b) / 2, (b - a) / 2⟩ of an interval [a, b].

                Equations
                Instances For

                  The interval of a ball has the points of the ball.

                  The ball of an interval has the points of the interval.

                  @[simp]

                  Turning an interval into a ball and back gives the interval.

                  @[simp]

                  Turning a ball into an interval and back gives the ball.

                  Balls and intervals in ℝ are the same: ConvexAnalysis.Ball.toInterval is an order isomorphism from balls with van der Hoeven's order onto intervals ordered by inclusion.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    The length of the interval of a ball is twice the radius.

                    theorem ConvexAnalysis.Ball.toInterval_add (B₁ B₂ : Ball ℝ) :
                    (B₁ + B₂).toInterval = B₁.toInterval + B₂.toInterval

                    Ball addition in ℝ is interval addition.

                    Ball negation in ℝ is interval negation.

                    theorem ConvexAnalysis.Ball.radius_mul_le_of_forall_mul_mem_Icc (B₁ B₂ : Ball ℝ) {l u : ℝ} (h : ∀ x ∈ B₁, ∀ y ∈ B₂, x * y ∈ Set.Icc l u) :
                    ↑(B₁ * B₂).radius ≤ 3 / 4 * (u - l)

                    Rump's overestimation bound: in ℝ, if [l, u] contains every product x y with x ∈ B₁ and y ∈ B₂, then the radius of the ball product B₁ * B₂ is at most 3 / 2 times the radius (u - l) / 2 of [l, u] Rump, Fast and parallel interval arithmetic. For the interval product, the smallest such interval, this bounds the overestimation of midpoint–radius multiplication; ball products contain the interval product by mul_mem_mul.

                    The inclusion tactic's interface #

                    @[instance_reducible]

                    Any of two enclosures of x is an enclosure of x; the one with the smaller radius is kept. This is the Refine operation of Mathlib's inclusion tactic.

                    Equations
                    @[instance_reducible]

                    The ball around the center of B₁ that contains B₁ and B₂, the Coarsen operation of Mathlib's inclusion tactic.

                    Equations
                    • One or more equations did not get rendered due to their size.