Documentation

ConvexAnalysis.IntervalDyadic

Verified interval evaluation with dyadic endpoints #

The interval theory of ConvexAnalysis.IntervalArithmetic and ConvexAnalysis.IntervalDerivative works with real intervals and describes computed results abstractly, as outward roundings (ConvexAnalysis.ArithExpr.IsRoundedEval). This file supplies the computation: an evaluator of arithmetic expressions with dyadic endpoints, built from the operations of Mathlib's inclusion tactic, whose results are outward roundings, and with it an interval Krawczyk test that the kernel evaluates. A successful test proves that a system of equations has exactly one solution in a box; no inequality has to be proved by hand.

Main definitions #

Main statements #

Implementation notes #

References #

Tags #

interval arithmetic, dyadic numbers, outward rounding, verified computation, Krawczyk test, computer-assisted proof, inclusion tactic, dyadic_interval

Bridge for the operations of the inclusion tactic on dyadic intervals #

An interval K of the inclusion tactic with dyadic endpoints whose conversion Z is defined contains every interval Y all of whose points lie in K.

Rational constants of the inclusion tactic (Inclusion.IntervalDyadicReal.rat): the dyadic interval of a rational number q contains q.

Outward rounding of the inclusion tactic (Inclusion.IntervalDyadicReal.roundOut, the endpoints rounded outward to multiples of 2⁻ᵖʳᵉᶜ) contains the interval it rounds.

The exponential of the inclusion tactic is an outward rounding: the dyadic interval Inclusion.IntervalDyadicReal.exp I prec (Taylor series with remainder bound at the endpoints), whenever its conversion is defined, contains the exact interval exponential ConvexAnalysis.IntervalArith.exp of the conversion of I.

The logarithm of the inclusion tactic is an outward rounding: for an interval of positive numbers, the dyadic interval Inclusion.IntervalDyadicReal.log I prec, whenever its conversion is defined, contains the exact interval logarithm ConvexAnalysis.IntervalArith.log. (The tactic's logarithm is defined for all intervals, as Mathlib's Real.log with log x = log |x|; the library's logarithm needs positivity.)

The square root of the inclusion tactic is an outward rounding: the dyadic interval Inclusion.IntervalDyadicReal.sqrt I prec (from Nat.sqrt of the scaled endpoints), whenever its conversion is defined, contains the exact interval square root ConvexAnalysis.IntervalArith.sqrt. No sign condition is needed, since both use Mathlib's Real.sqrt.

The power of the inclusion tactic is an outward rounding: the dyadic interval I.pow k (Inclusion.Interval.pow, exact on the dyadic endpoints, with the case of an even power of an interval containing 0), whenever its conversion is defined, contains the exact interval power ConvexAnalysis.IntervalArith.pow.

The inverse of a dyadic interval #

A dyadic lower bound of the rational number q, at the precision 2⁻ᵖʳᵉᶜ.

Equations
Instances For

    A dyadic upper bound of the rational number q, at the precision 2⁻ᵖʳᵉᶜ.

    Equations
    Instances For

      The inverse of an interval [a, b] of the inclusion tactic with dyadic endpoints that does not contain 0: the interval [1 / b, 1 / a] with the endpoints rounded outward to multiples of 2⁻ᵖʳᵉᶜ; the whole line if the interval is unbounded or may contain 0. Mathlib's inclusion tactic has no inverse yet (open PR #46311 adds division).

      Equations
      Instances For

        The inclusion property of the dyadic inverse.

        The dyadic inverse is an outward rounding: for an interval not containing 0, ConvexAnalysis.DyadicInterval.inv I prec, whenever its conversion is defined, contains the exact interval inverse ConvexAnalysis.IntervalArith.inv.

        Intervals with dyadic endpoints #

        The real interval [a, b] denoted by an interval D = [a, b] with dyadic endpoints.

        Equations
        Instances For

          A dyadic interval as an interval Inclusion.Interval Dyadic of Mathlib's inclusion tactic.

          Equations
          Instances For

            The dyadic interval [a, b] of an interval of the inclusion tactic with finite endpoints a ≤ b; none otherwise.

            Equations
            Instances For

              The points of toReal D are the real points of the interval toInterval D of the inclusion tactic.

              If ofInterval I = some D, the points of toReal D are the real points of I.

              The dyadic interval [⌊a⌋, ⌈b⌉] (endpoints rounded outward to multiples of 2⁻ᵖʳᵉᶜ) for rational a, b; it contains [a, b]. If b < a, the upper endpoint is raised to the lower one.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                theorem ConvexAnalysis.DyadicInterval.mem_toReal_ofRat {x : ℝ} {a b : ℚ} (prec : ℕ) (ha : ↑a ≤ x) (hb : x ≤ ↑b) :
                x ∈ toReal (ofRat a b prec)

                ConvexAnalysis.DyadicInterval.ofRat a b prec contains every real x with a ≤ x ≤ b.

                Expressions with rational constants and their dyadic evaluation #

                inductive ConvexAnalysis.RatArithExpr (ι : Type u_1) :
                Type u_1

                Arithmetic expressions with rational constants, the computable counterpart of ConvexAnalysis.ArithExpr (whose constants are real numbers): the same constructors, with constants in ℚ. ConvexAnalysis.RatArithExpr.toArithExpr maps them to ArithExpr.

                Instances For

                  The difference e₁ - e₂ = e₁ + (-e₂).

                  Equations
                  Instances For

                    The quotient e₁ / e₂ = e₁ * e₂⁻¹.

                    Equations
                    Instances For
                      @[instance_reducible]

                      The notation e₁ + e₂ for RatArithExpr.add.

                      Equations
                      @[instance_reducible]

                      The notation e₁ - e₂ for RatArithExpr.sub.

                      Equations
                      @[instance_reducible]

                      The notation e₁ * e₂ for RatArithExpr.mul.

                      Equations
                      @[instance_reducible]

                      The notation e₁ / e₂ for RatArithExpr.div.

                      Equations
                      @[instance_reducible]

                      Numerals (n : RatArithExpr ι) are constants.

                      Equations
                      @[simp]
                      theorem ConvexAnalysis.RatArithExpr.add_eq {ι : Type u_1} (e₁ e₂ : RatArithExpr ι) :
                      e₁ + e₂ = e₁.add e₂

                      e₁ + e₂ is RatArithExpr.add e₁ e₂.

                      @[simp]
                      theorem ConvexAnalysis.RatArithExpr.neg_eq {ι : Type u_1} (e : RatArithExpr ι) :
                      -e = e.neg

                      -e is RatArithExpr.neg e.

                      @[simp]
                      theorem ConvexAnalysis.RatArithExpr.sub_eq {ι : Type u_1} (e₁ e₂ : RatArithExpr ι) :
                      e₁ - e₂ = e₁.sub e₂

                      e₁ - e₂ is RatArithExpr.sub e₁ e₂.

                      @[simp]
                      theorem ConvexAnalysis.RatArithExpr.mul_eq {ι : Type u_1} (e₁ e₂ : RatArithExpr ι) :
                      e₁ * e₂ = e₁.mul e₂

                      e₁ * e₂ is RatArithExpr.mul e₁ e₂.

                      @[simp]

                      e⁻¹ is RatArithExpr.inv e.

                      @[simp]
                      theorem ConvexAnalysis.RatArithExpr.div_eq {ι : Type u_1} (e₁ e₂ : RatArithExpr ι) :
                      e₁ / e₂ = e₁.div e₂

                      e₁ / e₂ is RatArithExpr.div e₁ e₂.

                      @[simp]
                      theorem ConvexAnalysis.RatArithExpr.pow_eq {ι : Type u_1} (e : RatArithExpr ι) (k : ℕ) :
                      e ^ k = e.pow k

                      e ^ k is RatArithExpr.pow e k.

                      @[simp]

                      A numeral is a constant.

                      The symbolic partial derivative with respect to x i, by the rules of ConvexAnalysis.ArithExpr.pderiv (ConvexAnalysis.RatArithExpr.toArithExpr_pderiv).

                      Equations
                      Instances For

                        The dyadic interval evaluation of an expression on the box X of dyadic intervals, at the precision 2⁻ᵖʳᵉᶜ: constants are enclosed by Inclusion.IntervalDyadicReal.rat, + and - are the exact operations of the inclusion tactic, products and powers are its operations rounded outward by Inclusion.IntervalDyadicReal.roundOut, exp, log and √ are its operations, and the inverse is ConvexAnalysis.DyadicInterval.inv. It is none if an inverse is applied to an interval that may contain 0, a logarithm to one that may contain a nonpositive number, a square root to one that may contain a negative number, or if an operation returns an unbounded interval. The function is computable and can be evaluated by the kernel (decide +kernel); its results are outward roundings (ConvexAnalysis.RatArithExpr.isRoundedEval_dyadicEval).

                        Equations
                        Instances For

                          The dyadic evaluation is an outward rounding: if e.dyadicEval prec X = some D and the real box Xr lies in the box of X, then toReal D is a rounded evaluation of the expression e.toArithExpr on Xr in the sense of ConvexAnalysis.ArithExpr.IsRoundedEval. So every theorem stated with IsRoundedEval hypotheses applies to the results of the computation: the fundamental theorem of interval arithmetic, derivative and slope enclosures, and the Krawczyk and interval Newton tests of ConvexAnalysis.IntervalDerivative.

                          The dyadic evaluation on the box X is a rounded evaluation on the real box of X.

                          theorem ConvexAnalysis.RatArithExpr.eval_mem_of_dyadicEval {ι : Type u_1} {prec : ℕ} {X : ι → NonemptyInterval Dyadic} {Xr : ι → NonemptyInterval ℝ} {e : RatArithExpr ι} {D : NonemptyInterval Dyadic} (hX : ∀ (i : ι), Xr i ≤ DyadicInterval.toReal (X i)) (h : dyadicEval prec X e = some D) {x : ι → ℝ} (hx : x ∈ IntervalArith.box Xr) :

                          Fundamental theorem for the dyadic evaluation: the value of e at every point of the real box Xr lies in the computed interval.

                          The Krawczyk test computed with dyadic intervals #

                          The sum ∑ j, f j of intervals of the inclusion tactic over Fin n, with the tactic's addition.

                          Equations
                          Instances For

                            isInside I a b: the interval I of the inclusion tactic is bounded, and its dyadic endpoints lie strictly between the rationals a and b.

                            Equations
                            Instances For
                              theorem ConvexAnalysis.DyadicInterval.mem_Ioo_of_isInside {I : Inclusion.Interval Dyadic} {a b : ℚ} (h : isInside I a b = true) {x : ℝ} (hx : x ∈ I) :
                              x ∈ Set.Ioo ↑a ↑b

                              The points of an interval I with isInside I a b lie in the open interval (a, b).

                              def ConvexAnalysis.DyadicInterval.krawczyk {n : ℕ} (prec : ℕ) (Fx₀ : Fin n → Inclusion.Interval Dyadic) (M : Fin n → Fin n → Inclusion.Interval Dyadic) (Y : Matrix (Fin n) (Fin n) ℚ) (x₀ : Fin n → ℚ) (X : Fin n → Inclusion.Interval Dyadic) (i : Fin n) :

                              The i-th side of the Krawczyk operator x₀ - Y F(x₀) + (1 - Y M) (X - x₀) in dyadic interval arithmetic, for enclosures Fx₀ k of the values F k (x₀), an interval matrix M, a rational matrix Y, a rational point x₀ and a box X; products are rounded outward to multiples of 2⁻ᵖʳᵉᶜ. It encloses the interval Krawczyk operator ConvexAnalysis.intervalKrawczyk (ConvexAnalysis.DyadicInterval.mem_krawczyk_of_mem_intervalKrawczyk).

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

                                The operations of real interval arithmetic and of the inclusion tactic, compared point by point: if the real arguments lie in the tactic's arguments, so does the real result.

                                A rational point interval lies in the tactic's interval of the rational.

                                theorem ConvexAnalysis.DyadicInterval.forall_mem_add {R₁ R₂ : NonemptyInterval ℝ} {I₁ I₂ : Inclusion.Interval Dyadic} (h₁ : ∀ y ∈ R₁, y ∈ I₁) (h₂ : ∀ y ∈ R₂, y ∈ I₂) (y : ℝ) :
                                y ∈ R₁ + R₂ → y ∈ I₁.add I₂

                                Interval addition, compared with the tactic's addition.

                                theorem ConvexAnalysis.DyadicInterval.forall_mem_sub {R₁ R₂ : NonemptyInterval ℝ} {I₁ I₂ : Inclusion.Interval Dyadic} (h₁ : ∀ y ∈ R₁, y ∈ I₁) (h₂ : ∀ y ∈ R₂, y ∈ I₂) (y : ℝ) :
                                y ∈ R₁ - R₂ → y ∈ I₁.sub I₂

                                Interval subtraction, compared with the tactic's subtraction.

                                theorem ConvexAnalysis.DyadicInterval.forall_mem_roundOut_mul {R₁ R₂ : NonemptyInterval ℝ} {I₁ I₂ : Inclusion.Interval Dyadic} (prec : ℕ) (h₁ : ∀ y ∈ R₁, y ∈ I₁) (h₂ : ∀ y ∈ R₂, y ∈ I₂) (y : ℝ) :

                                Interval multiplication, compared with the tactic's multiplication rounded outward.

                                theorem ConvexAnalysis.DyadicInterval.forall_mem_sum {n : ℕ} {R : Fin n → NonemptyInterval ℝ} {f : Fin n → Inclusion.Interval Dyadic} (h : ∀ (j : Fin n), ∀ y ∈ R j, y ∈ f j) (y : ℝ) :
                                y ∈ ∑ j : Fin n, R j → y ∈ DyadicInterval.sum f

                                Sums of intervals, compared with ConvexAnalysis.DyadicInterval.sum.

                                theorem ConvexAnalysis.DyadicInterval.mem_krawczyk_of_mem_intervalKrawczyk {n prec : ℕ} {Fx₀ : Fin n → Inclusion.Interval Dyadic} {M : Fin n → Fin n → Inclusion.Interval Dyadic} {Y : Matrix (Fin n) (Fin n) ℚ} {x₀ : Fin n → ℚ} {X : Fin n → Inclusion.Interval Dyadic} {Fr Xr : Fin n → NonemptyInterval ℝ} {Mr : Fin n → Fin n → NonemptyInterval ℝ} (hF : ∀ (k : Fin n), ∀ y ∈ Fr k, y ∈ Fx₀ k) (hM : ∀ (k j : Fin n), ∀ y ∈ Mr k j, y ∈ M k j) (hX : ∀ (j : Fin n), ∀ y ∈ Xr j, y ∈ X j) (i : Fin n) (y : ℝ) :
                                y ∈ intervalKrawczyk Fr Mr (Y.map Rat.cast) (fun (j : Fin n) => ↑(x₀ j)) Xr i → y ∈ DyadicInterval.krawczyk prec Fx₀ M Y x₀ X i

                                The dyadic Krawczyk operator encloses the interval Krawczyk operator: if the points of the real intervals Fr k, Mr k j and Xr j lie in the dyadic intervals Fx₀ k, M k j and X j, then every point of the side i of ConvexAnalysis.intervalKrawczyk with the rational matrix Y and point x₀ lies in the side i of ConvexAnalysis.DyadicInterval.krawczyk.

                                def ConvexAnalysis.RatArithExpr.krawczykTest {n : ℕ} (prec : ℕ) (F : Fin n → RatArithExpr (Fin n)) (lo hi x₀ : Fin n → ℚ) (Y : Matrix (Fin n) (Fin n) ℚ) :

                                The interval Krawczyk test computed with dyadic intervals for the system F : Fin n → RatArithExpr (Fin n) on the box [lo, hi], with the rational point x₀ and the rational matrix Y (an approximate inverse of the Jacobian at x₀), at the precision 2⁻ᵖʳᵉᶜ. It checks that lo ≤ x₀ ≤ hi, evaluates F at x₀ and the symbolic partial derivatives ConvexAnalysis.RatArithExpr.pderiv j (F k) on a dyadic box containing [lo, hi] with ConvexAnalysis.RatArithExpr.dyadicEval, and checks that every side of the dyadic Krawczyk operator ConvexAnalysis.DyadicInterval.krawczyk lies strictly inside (lo i, hi i). The test is computable and is evaluated by the kernel; if it returns true, the system has exactly one zero in the box (ConvexAnalysis.RatArithExpr.existsUnique_eq_zero_of_krawczykTest).

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  theorem ConvexAnalysis.RatArithExpr.existsUnique_eq_zero_of_krawczykTest {n prec : ℕ} {F : Fin n → RatArithExpr (Fin n)} {lo hi x₀ : Fin n → ℚ} {Y : Matrix (Fin n) (Fin n) ℚ} (h : krawczykTest prec F lo hi x₀ Y = true) :
                                  ∃! x : Fin n → ℝ, (x ∈ Set.Icc (fun (i : Fin n) => ↑(lo i)) fun (i : Fin n) => ↑(hi i)) ∧ (fun (k : Fin n) => ArithExpr.eval x (F k).toArithExpr) = 0

                                  A verified computation of a unique zero: if the dyadic Krawczyk test ConvexAnalysis.RatArithExpr.krawczykTest succeeds, the system of equations (F k).toArithExpr.eval x = 0 has exactly one solution x in the box [lo, hi]. Nothing else is assumed: differentiability, the slope enclosure and the inclusion of the Krawczyk operator in the interior of the box follow from the computation, so the hypothesis can be proved by decide +kernel. This is the strict Krawczyk test (Neumaier, Theorem 5.1.8 (iii)) in the form ConvexAnalysis.existsUnique_eq_zero_of_intervalKrawczyk_pderiv, with slopes from interval differentiation and all inputs computed in dyadic interval arithmetic (ConvexAnalysis.RatArithExpr.isRoundedEval_dyadicEval, ConvexAnalysis.DyadicInterval.mem_krawczyk_of_mem_intervalKrawczyk).

                                  @[reducible, inline]
                                  abbrev ConvexAnalysis.RatArithExpr.HasUniqueZero {n : ℕ} (F : Fin n → RatArithExpr (Fin n)) (lo hi : Fin n → ℚ) :

                                  HasUniqueZero F lo hi: the system of equations (F k).toArithExpr.eval x = 0 has exactly one solution x in the rational box [lo, hi]. This is the conclusion of the dyadic existence tests (ConvexAnalysis.RatArithExpr.existsUnique_eq_zero_of_krawczykTest, ConvexAnalysis.RatArithExpr.existsUnique_eq_zero_of_hansenSenguptaTest), and the hypothesis of the theorems that restate it for one variable, complex zeros, eigenpairs and matrix square roots (ConvexAnalysis.RatArithExpr.existsUnique_eq_zero_real_of_hasUniqueZero), so that these serve every test.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    theorem ConvexAnalysis.RatArithExpr.existsUnique_eq_zero_real_of_hasUniqueZero {e : RatArithExpr (Fin 1)} {lo hi : ℚ} (h : HasUniqueZero (fun (x : Fin 1) => e) (fun (x : Fin 1) => lo) fun (x : Fin 1) => hi) :
                                    ∃! x : ℝ, x ∈ Set.Icc ↑lo ↑hi ∧ ArithExpr.eval (fun (x_1 : Fin 1) => x) e.toArithExpr = 0

                                    One equation in one variable: if the system fun _ ↦ e in one variable has exactly one zero in the box [lo, hi] (for example by ConvexAnalysis.RatArithExpr.existsUnique_eq_zero_of_krawczykTest), then e(x) = 0 has exactly one solution x : ℝ in [lo, hi]; the statement on ℝ instead of Fin 1 → ℝ, with the suffix _real as in ConvexAnalysis.existsUnique_eq_zero_of_radii_polynomial_real.

                                    theorem ConvexAnalysis.RatArithExpr.existsUnique_eq_zero_of_krawczykTest_real {prec : ℕ} {e : RatArithExpr (Fin 1)} {lo hi x₀ y : ℚ} (h : (krawczykTest prec (fun (x : Fin 1) => e) (fun (x : Fin 1) => lo) (fun (x : Fin 1) => hi) (fun (x : Fin 1) => x₀) fun (x x_1 : Fin 1) => y) = true) :
                                    ∃! x : ℝ, x ∈ Set.Icc ↑lo ↑hi ∧ ArithExpr.eval (fun (x_1 : Fin 1) => x) e.toArithExpr = 0

                                    The dyadic Krawczyk test for one equation e(x) = 0 in one real variable (the case n = 1 of ConvexAnalysis.RatArithExpr.existsUnique_eq_zero_of_krawczykTest, stated on ℝ by ConvexAnalysis.RatArithExpr.existsUnique_eq_zero_real_of_hasUniqueZero): if the test succeeds with the rational interval [lo, hi], the point x₀ and the approximate inverse y of e'(x₀), then e(x) = 0 has exactly one solution in [lo, hi].