# Documentation

Mathlib.Algebra.Order.Interval

# Interval arithmetic #

This file defines arithmetic operations on intervals and prove their correctness. Note that this is full precision operations. The essentials of float operations can be found in Data.FP.Basic. We have not yet integrated these with the rest of the library.

### One/zero #

instance instZeroNonemptyIntervalToLE {α : Type u_2} [] [Zero α] :
instance instOneNonemptyIntervalToLE {α : Type u_2} [] [One α] :
instance instZeroIntervalToLE {α : Type u_2} [] [Zero α] :
Zero ()
instance instOneIntervalToLE {α : Type u_2} [] [One α] :
One ()
@[simp]
theorem NonemptyInterval.toProd_zero {α : Type u_2} [] [Zero α] :
0.toProd = 0
@[simp]
theorem NonemptyInterval.toProd_one {α : Type u_2} [] [One α] :
1.toProd = 1
theorem NonemptyInterval.fst_zero {α : Type u_2} [] [Zero α] :
0.fst = 0
theorem NonemptyInterval.fst_one {α : Type u_2} [] [One α] :
1.fst = 1
theorem NonemptyInterval.snd_zero {α : Type u_2} [] [Zero α] :
0.snd = 0
theorem NonemptyInterval.snd_one {α : Type u_2} [] [One α] :
1.snd = 1
@[simp]
theorem NonemptyInterval.coe_zero_interval {α : Type u_2} [] [Zero α] :
0 = 0
@[simp]
theorem NonemptyInterval.coe_one_interval {α : Type u_2} [] [One α] :
1 = 1
@[simp]
theorem NonemptyInterval.pure_zero {α : Type u_2} [] [Zero α] :
@[simp]
theorem NonemptyInterval.pure_one {α : Type u_2} [] [One α] :
@[simp]
theorem Interval.pure_zero {α : Type u_2} [] [Zero α] :
@[simp]
theorem Interval.pure_one {α : Type u_2} [] [One α] :
@[simp]
theorem Interval.zero_ne_bot {α : Type u_2} [] [Zero α] :
@[simp]
theorem Interval.one_ne_bot {α : Type u_2} [] [One α] :
@[simp]
theorem Interval.bot_ne_zero {α : Type u_2} [] [Zero α] :
@[simp]
theorem Interval.bot_ne_one {α : Type u_2} [] [One α] :
@[simp]
theorem NonemptyInterval.coe_zero {α : Type u_2} [] [Zero α] :
0 = 0
@[simp]
theorem NonemptyInterval.coe_one {α : Type u_2} [] [One α] :
1 = 1
theorem NonemptyInterval.zero_mem_zero {α : Type u_2} [] [Zero α] :
0 0
theorem NonemptyInterval.one_mem_one {α : Type u_2} [] [One α] :
1 1
@[simp]
theorem Interval.coe_zero {α : Type u_2} [] [Zero α] :
0 = 0
@[simp]
theorem Interval.coe_one {α : Type u_2} [] [One α] :
1 = 1
theorem Interval.zero_mem_zero {α : Type u_2} [] [Zero α] :
0 0
theorem Interval.one_mem_one {α : Type u_2} [] [One α] :
1 1

Note that this multiplication does not apply to ℚ or ℝ.

theorem instAddNonemptyIntervalToLE.proof_1 {α : Type u_1} [] [Add α] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] (s : ) (t : ) :
s.fst + t.fst s.snd + t.snd
instance instAddNonemptyIntervalToLE {α : Type u_2} [] [Add α] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] :
instance instMulNonemptyIntervalToLE {α : Type u_2} [] [Mul α] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x * x_1) fun x x_1 => x x_1] :
instance instAddIntervalToLE {α : Type u_2} [] [Add α] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] :
instance instMulIntervalToLE {α : Type u_2} [] [Mul α] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x * x_1) fun x x_1 => x x_1] :
Mul ()
@[simp]
theorem NonemptyInterval.toProd_add {α : Type u_2} [] [Add α] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] (s : ) (t : ) :
(s + t).toProd = s.toProd + t.toProd
@[simp]
theorem NonemptyInterval.toProd_mul {α : Type u_2} [] [Mul α] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x * x_1) fun x x_1 => x x_1] (s : ) (t : ) :
(s * t).toProd = s.toProd * t.toProd
theorem NonemptyInterval.fst_add {α : Type u_2} [] [Add α] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] (s : ) (t : ) :
(s + t).fst = s.fst + t.fst
theorem NonemptyInterval.fst_mul {α : Type u_2} [] [Mul α] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x * x_1) fun x x_1 => x x_1] (s : ) (t : ) :
(s * t).fst = s.fst * t.fst
theorem NonemptyInterval.snd_add {α : Type u_2} [] [Add α] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] (s : ) (t : ) :
(s + t).snd = s.snd + t.snd
theorem NonemptyInterval.snd_mul {α : Type u_2} [] [Mul α] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x * x_1) fun x x_1 => x x_1] (s : ) (t : ) :
(s * t).snd = s.snd * t.snd
@[simp]
theorem NonemptyInterval.coe_add_interval {α : Type u_2} [] [Add α] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] (s : ) (t : ) :
↑(s + t) = s + t
@[simp]
theorem NonemptyInterval.coe_mul_interval {α : Type u_2} [] [Mul α] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x * x_1) fun x x_1 => x x_1] (s : ) (t : ) :
↑(s * t) = s * t
@[simp]
theorem NonemptyInterval.pure_add_pure {α : Type u_2} [] [Add α] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] (a : α) (b : α) :
@[simp]
theorem NonemptyInterval.pure_mul_pure {α : Type u_2} [] [Mul α] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x * x_1) fun x x_1 => x x_1] (a : α) (b : α) :
@[simp]
theorem Interval.bot_add {α : Type u_2} [] [Add α] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] (t : ) :
@[simp]
theorem Interval.bot_mul {α : Type u_2} [] [Mul α] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x * x_1) fun x x_1 => x x_1] (t : ) :
theorem Interval.add_bot {α : Type u_2} [] [Add α] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] (s : ) :
@[simp]
theorem Interval.mul_bot {α : Type u_2} [] [Mul α] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x * x_1) fun x x_1 => x x_1] (s : ) :

### Powers #

instance NonemptyInterval.hasNsmul {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] :
instance NonemptyInterval.hasPow {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x * x_1) fun x x_1 => x x_1] :
@[simp]
theorem NonemptyInterval.toProd_nsmul {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] (s : ) (n : ) :
(n s).toProd = n s.toProd
@[simp]
theorem NonemptyInterval.toProd_pow {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x * x_1) fun x x_1 => x x_1] (s : ) (n : ) :
(s ^ n).toProd = s.toProd ^ n
theorem NonemptyInterval.fst_nsmul {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] (s : ) (n : ) :
(n s).fst = n s.fst
theorem NonemptyInterval.fst_pow {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x * x_1) fun x x_1 => x x_1] (s : ) (n : ) :
(s ^ n).fst = s.fst ^ n
theorem NonemptyInterval.snd_nsmul {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] (s : ) (n : ) :
(n s).snd = n s.snd
theorem NonemptyInterval.snd_pow {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x * x_1) fun x x_1 => x x_1] (s : ) (n : ) :
(s ^ n).snd = s.snd ^ n
@[simp]
theorem NonemptyInterval.pure_nsmul {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] (a : α) (n : ) :
@[simp]
theorem NonemptyInterval.pure_pow {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] [CovariantClass α α (Function.swap fun x x_1 => x * x_1) fun x x_1 => x x_1] (a : α) (n : ) :
theorem NonemptyInterval.addCommMonoid.proof_3 {α : Type u_1} (s : ) (t : ) :
(s + t).toProd = s.toProd + t.toProd
theorem NonemptyInterval.addCommMonoid.proof_2 {α : Type u_1} :
0.toProd = 0
theorem NonemptyInterval.addCommMonoid.proof_1 {α : Type u_1} :
Function.Injective NonemptyInterval.toProd
theorem NonemptyInterval.addCommMonoid.proof_4 {α : Type u_1} (s : ) (n : ) :
(n s).toProd = n s.toProd
theorem Interval.addZeroClass.proof_1 {α : Type u_1} (s : ) :
Option.map₂ (fun x x_1 => x + x_1) () s = s
theorem Interval.addZeroClass.proof_2 {α : Type u_1} (s : ) :
Option.map₂ (fun x x_1 => x + x_1) s () = s
instance Interval.addZeroClass {α : Type u_2} :
instance Interval.mulOneClass {α : Type u_2} :
theorem Interval.addCommMonoid.proof_4 {α : Type u_1} :
∀ (x : ), nsmulRec 0 x = nsmulRec 0 x
theorem Interval.addCommMonoid.proof_5 {α : Type u_1} :
∀ (n : ) (x : ), nsmulRec (n + 1) x = nsmulRec (n + 1) x
theorem Interval.addCommMonoid.proof_6 {α : Type u_1} :
∀ (x x_1 : ), Option.map₂ (fun x x_2 => x + x_2) x x_1 = Option.map₂ (fun x x_2 => x + x_2) x_1 x
theorem Interval.addCommMonoid.proof_1 {α : Type u_1} :
∀ (x x_1 x_2 : ), Option.map₂ (fun x x_3 => x + x_3) (Option.map₂ (fun x x_3 => x + x_3) x x_1) x_2 = Option.map₂ (fun x x_3 => x + x_3) x (Option.map₂ (fun x x_3 => x + x_3) x_1 x_2)
theorem Interval.addCommMonoid.proof_2 {α : Type u_1} (a : ) :
0 + a = a
theorem Interval.addCommMonoid.proof_3 {α : Type u_1} (a : ) :
a + 0 = a
instance Interval.addCommMonoid {α : Type u_2} :
instance Interval.commMonoid {α : Type u_2} :
theorem NonemptyInterval.coe_nsmul_interval {α : Type u_2} (s : ) (n : ) :
↑(n s) = n s
@[simp]
theorem NonemptyInterval.coe_pow_interval {α : Type u_2} (s : ) (n : ) :
↑(s ^ n) = s ^ n
abbrev Interval.bot_nsmul.match_1 (motive : (x : ) → x 0Prop) :
(x : ) → (x_1 : x 0) → ((h : 0 0) → motive 0 h) → ((n : ) → (x : 0) → motive () x) → motive x x_1
Instances For
theorem Interval.bot_nsmul {α : Type u_2} {n : } :
n 0n =
theorem Interval.bot_pow {α : Type u_2} {n : } :
n 0 ^ n =

### Subtraction #

Subtraction is defined more generally than division so that it applies to ℕ (and OrderedDiv is not a thing and probably should not become one).

instance instSubNonemptyIntervalToLE {α : Type u_2} [] [] [Sub α] [] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] :
instance instSubIntervalToLE {α : Type u_2} [] [] [Sub α] [] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] :
Sub ()
@[simp]
theorem NonemptyInterval.fst_sub {α : Type u_2} [] [] [Sub α] [] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] (s : ) (t : ) :
(s - t).fst = s.fst - t.snd
@[simp]
theorem NonemptyInterval.snd_sub {α : Type u_2} [] [] [Sub α] [] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] (s : ) (t : ) :
(s - t).snd = s.snd - t.fst
@[simp]
theorem NonemptyInterval.coe_sub_interval {α : Type u_2} [] [] [Sub α] [] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] (s : ) (t : ) :
↑(s - t) = s - t
theorem NonemptyInterval.sub_mem_sub {α : Type u_2} [] [] [Sub α] [] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] (s : ) (t : ) {a : α} {b : α} (ha : a s) (hb : b t) :
a - b s - t
@[simp]
theorem NonemptyInterval.pure_sub_pure {α : Type u_2} [] [] [Sub α] [] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] (a : α) (b : α) :
@[simp]
theorem Interval.bot_sub {α : Type u_2} [] [] [Sub α] [] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] (t : ) :
@[simp]
theorem Interval.sub_bot {α : Type u_2} [] [] [Sub α] [] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] (s : ) :

### Division in ordered groups #

Note that this division does not apply to ℚ or ℝ.

instance instDivNonemptyIntervalToLE {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] :
instance instDivIntervalToLE {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] :
Div ()
@[simp]
theorem NonemptyInterval.fst_div {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] (s : ) (t : ) :
(s / t).fst = s.fst / t.snd
@[simp]
theorem NonemptyInterval.snd_div {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] (s : ) (t : ) :
(s / t).snd = s.snd / t.fst
@[simp]
theorem NonemptyInterval.coe_div_interval {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] (s : ) (t : ) :
↑(s / t) = s / t
theorem NonemptyInterval.div_mem_div {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] (s : ) (t : ) (a : α) (b : α) (ha : a s) (hb : b t) :
a / b s / t
@[simp]
theorem NonemptyInterval.pure_div_pure {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] (a : α) (b : α) :
@[simp]
theorem Interval.bot_div {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] (t : ) :
@[simp]
theorem Interval.div_bot {α : Type u_2} [] [] [CovariantClass α α (fun x x_1 => x * x_1) fun x x_1 => x x_1] (s : ) :

### Negation/inversion #

@[simp]
theorem NonemptyInterval.fst_neg {α : Type u_2} (s : ) :
(-s).fst = -s.snd
@[simp]
theorem NonemptyInterval.fst_inv {α : Type u_2} [] (s : ) :
s⁻¹.fst = s.snd⁻¹
@[simp]
theorem NonemptyInterval.snd_neg {α : Type u_2} (s : ) :
(-s).snd = -s.fst
@[simp]
theorem NonemptyInterval.snd_inv {α : Type u_2} [] (s : ) :
s⁻¹.snd = s.fst⁻¹
@[simp]
theorem NonemptyInterval.coe_neg_interval {α : Type u_2} (s : ) :
↑(-s) = -s
@[simp]
theorem NonemptyInterval.coe_inv_interval {α : Type u_2} [] (s : ) :
s⁻¹ = (s)⁻¹
theorem NonemptyInterval.neg_mem_neg {α : Type u_2} (s : ) (a : α) (ha : a s) :
-a -s
theorem NonemptyInterval.inv_mem_inv {α : Type u_2} [] (s : ) (a : α) (ha : a s) :
@[simp]
theorem NonemptyInterval.neg_pure {α : Type u_2} (a : α) :
@[simp]
theorem NonemptyInterval.inv_pure {α : Type u_2} [] (a : α) :
@[simp]
theorem Interval.neg_bot {α : Type u_2} :
@[simp]
theorem Interval.inv_bot {α : Type u_2} [] :
theorem NonemptyInterval.add_eq_zero_iff {α : Type u_2} {s : } {t : } :
s + t = 0 a b, a + b = 0
theorem NonemptyInterval.mul_eq_one_iff {α : Type u_2} [] {s : } {t : } :
s * t = 1 a b, a * b = 1
theorem Interval.add_eq_zero_iff {α : Type u_2} {s : } {t : } :
s + t = 0 a b, a + b = 0
theorem Interval.mul_eq_one_iff {α : Type u_2} [] {s : } {t : } :
s * t = 1 a b, a * b = 1
instance Interval.divisionCommMonoid {α : Type u_2} [] :
def NonemptyInterval.length {α : Type u_2} (s : ) :
α

The length of an interval is its first component minus its second component. This measures the accuracy of the approximation by an interval.

Instances For
@[simp]
theorem NonemptyInterval.length_nonneg {α : Type u_2} (s : ) :
@[simp]
theorem NonemptyInterval.length_pure {α : Type u_2} (a : α) :
@[simp]
theorem NonemptyInterval.length_zero {α : Type u_2} :
@[simp]
theorem NonemptyInterval.length_neg {α : Type u_2} (s : ) :
@[simp]
theorem NonemptyInterval.length_add {α : Type u_2} (s : ) (t : ) :
@[simp]
theorem NonemptyInterval.length_sub {α : Type u_2} (s : ) (t : ) :
@[simp]
theorem NonemptyInterval.length_sum {ι : Type u_1} {α : Type u_2} (f : ι) (s : ) :
NonemptyInterval.length (Finset.sum s fun i => f i) = Finset.sum s fun i =>
def Interval.length {α : Type u_2} :
α

The length of an interval is its first component minus its second component. This measures the accuracy of the approximation by an interval.

Instances For
@[simp]
theorem Interval.length_nonneg {α : Type u_2} (s : ) :
@[simp]
theorem Interval.length_pure {α : Type u_2} (a : α) :
@[simp]
theorem Interval.length_zero {α : Type u_2} :
@[simp]
theorem Interval.length_neg {α : Type u_2} (s : ) :
theorem Interval.length_add_le {α : Type u_2} (s : ) (t : ) :
theorem Interval.length_sub_le {α : Type u_2} (s : ) (t : ) :
theorem Interval.length_sum_le {ι : Type u_1} {α : Type u_2} (f : ι) (s : ) :
Interval.length (Finset.sum s fun i => f i) Finset.sum s fun i => Interval.length (f i)

Extension for the positivity tactic: The length of an interval is always nonnegative.

Instances For

Extension for the positivity tactic: The length of an interval is always nonnegative.

Instances For