Documentation

LeanCert.Core.IntervalRat.Basic

Rational Endpoint Intervals - Core Definitions #

This file defines IntervalRat, a concrete interval type with rational endpoints suitable for computation. We prove the Fundamental Theorem of Interval Arithmetic (FTIA) for each operation.

Main definitions #

Main theorems #

Design notes #

All operations maintain the invariant lohi. Domain restrictions for partial operations (like inv) are encoded via separate types or explicit hypotheses.

An interval with rational endpoints

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

      Default interval [0, 0] for unsupported expression branches

      Equations

      The set of reals contained in this interval

      Equations
      Instances For
        @[simp]
        theorem LeanCert.Core.IntervalRat.mem_def (x : ) (I : IntervalRat) :
        x I I.lo x x I.hi

        Membership in IntervalRat is the same as membership in Set.Icc

        theorem LeanCert.Core.IntervalRat.forall_mem_iff_forall_Icc {P : Prop} (I : IntervalRat) :
        (∀ xI, P x) xSet.Icc I.lo I.hi, P x

        Universal quantifier over IntervalRat equals universal over Set.Icc

        theorem LeanCert.Core.IntervalRat.exists_mem_iff_exists_Icc {P : Prop} (I : IntervalRat) :
        (∃ xI, P x) xSet.Icc I.lo I.hi, P x

        Existence in IntervalRat equals existence in Set.Icc

        Create an interval from a single rational

        Equations
        Instances For

          The width of an interval

          Equations
          Instances For

            Midpoint of an interval

            Equations
            Instances For

              The midpoint of an interval is contained in the interval

              Interval addition #

              Add two intervals

              Equations
              Instances For
                theorem LeanCert.Core.IntervalRat.mem_add {x y : } {I J : IntervalRat} (hx : x I) (hy : y J) :
                x + y I.add J

                FTIA for addition

                Interval negation #

                Negate an interval

                Equations
                Instances For
                  theorem LeanCert.Core.IntervalRat.mem_neg {x : } {I : IntervalRat} (hx : x I) :
                  -x I.neg

                  FTIA for negation

                  Interval subtraction #

                  Subtract two intervals

                  Equations
                  Instances For
                    theorem LeanCert.Core.IntervalRat.mem_sub {x y : } {I J : IntervalRat} (hx : x I) (hy : y J) :
                    x - y I.sub J

                    FTIA for subtraction

                    Interval multiplication #

                    Helper: minimum of four rationals

                    Equations
                    Instances For

                      Helper: maximum of four rationals

                      Equations
                      Instances For
                        theorem LeanCert.Core.IntervalRat.min4_le_all (a b c d : ) :
                        min4 a b c d a min4 a b c d b min4 a b c d c min4 a b c d d
                        theorem LeanCert.Core.IntervalRat.all_le_max4 (a b c d : ) :
                        a max4 a b c d b max4 a b c d c max4 a b c d d max4 a b c d
                        theorem LeanCert.Core.IntervalRat.le_min4_iff (x a b c d : ) :
                        x min4 a b c d x a x b x c x d
                        theorem LeanCert.Core.IntervalRat.max4_le_iff (x a b c d : ) :
                        max4 a b c d x a x b x c x d x
                        @[implemented_by _private.LeanCert.Core.IntervalRat.Basic.0.LeanCert.Core.IntervalRat.mulFast]

                        Multiply two intervals

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          theorem LeanCert.Core.IntervalRat.mem_mul {x y : } {I J : IntervalRat} (hx : x I) (hy : y J) :
                          x * y I.mul J

                          FTIA for multiplication

                          theorem LeanCert.Core.IntervalRat.eq_min4_of_le {a b c d : } (h1 : a b) (h2 : a c) (h3 : a d) :
                          a = min4 a b c d

                          Helper: show a = min4 a b c d when a ≤ b, a ≤ c, a ≤ d

                          theorem LeanCert.Core.IntervalRat.eq_min4_of_le2 {a b c d : } (h1 : b a) (h2 : b c) (h3 : b d) :
                          b = min4 a b c d
                          theorem LeanCert.Core.IntervalRat.eq_min4_of_le3 {a b c d : } (h1 : c a) (h2 : c b) (h3 : c d) :
                          c = min4 a b c d
                          theorem LeanCert.Core.IntervalRat.eq_min4_of_le4 {a b c d : } (h1 : d a) (h2 : d b) (h3 : d c) :
                          d = min4 a b c d
                          theorem LeanCert.Core.IntervalRat.eq_max4_of_ge {a b c d : } (h1 : b a) (h2 : c a) (h3 : d a) :
                          a = max4 a b c d
                          theorem LeanCert.Core.IntervalRat.eq_max4_of_ge2 {a b c d : } (h1 : a b) (h2 : c b) (h3 : d b) :
                          b = max4 a b c d
                          theorem LeanCert.Core.IntervalRat.eq_max4_of_ge3 {a b c d : } (h1 : a c) (h2 : b c) (h3 : d c) :
                          c = max4 a b c d
                          theorem LeanCert.Core.IntervalRat.eq_max4_of_ge4 {a b c d : } (h1 : a d) (h2 : b d) (h3 : c d) :
                          d = max4 a b c d

                          Interval containing zero check #

                          Check if an interval contains zero

                          Equations
                          Instances For

                            An interval that is guaranteed not to contain zero

                            Instances For

                              Interval inversion (for nonzero intervals) #

                              Invert an interval that doesn't contain zero

                              Equations
                              Instances For

                                FTIA for inversion #

                                Scalar operations #

                                Scale an interval by a rational

                                Equations
                                Instances For
                                  theorem LeanCert.Core.IntervalRat.mem_scale {x : } {I : IntervalRat} (q : ) (hx : x I) :
                                  q * x scale q I

                                  FTIA for scaling

                                  Interval splitting #

                                  Split an interval at its midpoint

                                  Equations
                                  Instances For
                                    theorem LeanCert.Core.IntervalRat.mem_bisect_left {x : } {I : IntervalRat} (hx : x I) (hm : x I.midpoint) :
                                    x I.bisect.1
                                    theorem LeanCert.Core.IntervalRat.mem_bisect_right {x : } {I : IntervalRat} (hx : x I) (hm : I.midpoint x) :
                                    x I.bisect.2
                                    theorem LeanCert.Core.IntervalRat.midpoint_sub_lo (I : IntervalRat) :
                                    I.midpoint - I.lo = (I.hi - I.lo) / 2

                                    Distance from midpoint to lo is half the width

                                    theorem LeanCert.Core.IntervalRat.hi_sub_midpoint (I : IntervalRat) :
                                    I.hi - I.midpoint = (I.hi - I.lo) / 2

                                    Distance from hi to midpoint is half the width

                                    Midpoint is at least lo (real version)

                                    Midpoint is at most hi (real version)

                                    Left bisection is a subset of the original interval

                                    Right bisection is a subset of the original interval

                                    theorem LeanCert.Core.IntervalRat.mem_bisect_or {x : } {I : IntervalRat} (hx : x I) :
                                    x I.bisect.1 x I.bisect.2

                                    Any point in an interval is in one of its bisected halves

                                    The default interval [0,0] contains only 0

                                    Interval intersection #

                                    Intersect two intervals. Returns none if they don't intersect.

                                    Equations
                                    Instances For
                                      theorem LeanCert.Core.IntervalRat.mem_intersect {x : } {I J : IntervalRat} (hI : x I) (hJ : x J) :
                                      ∃ (K : IntervalRat), I.intersect J = some K x K

                                      If intersection succeeds, the result contains any point in both intervals

                                      If intersection returns some K, then K ⊆ I

                                      If intersection returns some K, then K ⊆ J