Interval arithmetic #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
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 #
Equations
Equations
Equations
- interval.has_one = {one := interval.pure 1}
Equations
- interval.has_zero = {zero := interval.pure 0}
Addition/multiplication #
Note that this multiplication does not apply to ℚ
or ℝ
.
Equations
- nonempty_interval.has_add = {add := λ (s t : nonempty_interval α), {to_prod := s.to_prod + t.to_prod, fst_le_snd := _}}
Equations
- nonempty_interval.has_mul = {mul := λ (s t : nonempty_interval α), {to_prod := s.to_prod * t.to_prod, fst_le_snd := _}}
Equations
Equations
Powers #
Equations
- nonempty_interval.has_nsmul = {smul := λ (n : ℕ) (s : nonempty_interval α), {to_prod := (n • s.to_prod.fst, n • s.to_prod.snd), fst_le_snd := _}}
Equations
- nonempty_interval.has_pow = {pow := λ (s : nonempty_interval α) (n : ℕ), {to_prod := s.to_prod ^ n, fst_le_snd := _}}
Equations
- nonempty_interval.comm_monoid = function.injective.comm_monoid nonempty_interval.to_prod nonempty_interval.comm_monoid._proof_1 nonempty_interval.comm_monoid._proof_2 nonempty_interval.comm_monoid._proof_3 nonempty_interval.comm_monoid._proof_4
Equations
- nonempty_interval.add_comm_monoid = function.injective.add_comm_monoid nonempty_interval.to_prod nonempty_interval.add_comm_monoid._proof_1 nonempty_interval.add_comm_monoid._proof_2 nonempty_interval.add_comm_monoid._proof_3 nonempty_interval.add_comm_monoid._proof_4
Equations
- interval.add_zero_class = {zero := 0, add := has_add.add interval.has_add, zero_add := _, add_zero := _}
Equations
- interval.mul_one_class = {one := 1, mul := has_mul.mul interval.has_mul, one_mul := _, mul_one := _}
Equations
- interval.comm_monoid = {mul := mul_one_class.mul interval.mul_one_class, mul_assoc := _, one := mul_one_class.one interval.mul_one_class, one_mul := _, mul_one := _, npow := monoid.npow._default mul_one_class.one mul_one_class.mul interval.comm_monoid._proof_4 interval.comm_monoid._proof_5, npow_zero' := _, npow_succ' := _, mul_comm := _}
Equations
- interval.add_comm_monoid = {add := add_zero_class.add interval.add_zero_class, add_assoc := _, zero := add_zero_class.zero interval.add_zero_class, zero_add := _, add_zero := _, nsmul := add_monoid.nsmul._default add_zero_class.zero add_zero_class.add interval.add_comm_monoid._proof_4 interval.add_comm_monoid._proof_5, nsmul_zero' := _, nsmul_succ' := _, add_comm := _}
Subtraction #
Subtraction is defined more generally than division so that it applies to ℕ
(and has_ordered_div
is not a thing and probably should not become one).
Equations
Division in ordered groups #
Note that this division does not apply to ℚ
or ℝ
.
Equations
Negation/inversion #
Equations
- nonempty_interval.has_inv = {inv := λ (s : nonempty_interval α), {to_prod := ((s.to_prod.snd)⁻¹, (s.to_prod.fst)⁻¹), fst_le_snd := _}}
Equations
- nonempty_interval.has_neg = {neg := λ (s : nonempty_interval α), {to_prod := (-s.to_prod.snd, -s.to_prod.fst), fst_le_snd := _}}
Equations
Equations
Equations
- nonempty_interval.subtraction_comm_monoid = {add := add_comm_monoid.add nonempty_interval.add_comm_monoid, add_assoc := _, zero := add_comm_monoid.zero nonempty_interval.add_comm_monoid, zero_add := _, add_zero := _, nsmul := add_comm_monoid.nsmul nonempty_interval.add_comm_monoid, nsmul_zero' := _, nsmul_succ' := _, neg := has_neg.neg nonempty_interval.has_neg, sub := has_sub.sub nonempty_interval.has_sub, sub_eq_add_neg := _, zsmul := subtraction_monoid.zsmul._default add_comm_monoid.add nonempty_interval.subtraction_comm_monoid._proof_8 add_comm_monoid.zero nonempty_interval.subtraction_comm_monoid._proof_9 nonempty_interval.subtraction_comm_monoid._proof_10 add_comm_monoid.nsmul nonempty_interval.subtraction_comm_monoid._proof_11 nonempty_interval.subtraction_comm_monoid._proof_12 has_neg.neg, zsmul_zero' := _, zsmul_succ' := _, zsmul_neg' := _, neg_neg := _, neg_add_rev := _, neg_eq_of_add := _, add_comm := _}
Equations
- nonempty_interval.division_comm_monoid = {mul := comm_monoid.mul nonempty_interval.comm_monoid, mul_assoc := _, one := comm_monoid.one nonempty_interval.comm_monoid, one_mul := _, mul_one := _, npow := comm_monoid.npow nonempty_interval.comm_monoid, npow_zero' := _, npow_succ' := _, inv := has_inv.inv nonempty_interval.has_inv, div := has_div.div nonempty_interval.has_div, div_eq_mul_inv := _, zpow := division_monoid.zpow._default comm_monoid.mul nonempty_interval.division_comm_monoid._proof_7 comm_monoid.one nonempty_interval.division_comm_monoid._proof_8 nonempty_interval.division_comm_monoid._proof_9 comm_monoid.npow nonempty_interval.division_comm_monoid._proof_10 nonempty_interval.division_comm_monoid._proof_11 has_inv.inv, zpow_zero' := _, zpow_succ' := _, zpow_neg' := _, inv_inv := _, mul_inv_rev := _, inv_eq_of_mul := _, mul_comm := _}
Equations
- interval.subtraction_comm_monoid = {add := add_comm_monoid.add interval.add_comm_monoid, add_assoc := _, zero := add_comm_monoid.zero interval.add_comm_monoid, zero_add := _, add_zero := _, nsmul := add_comm_monoid.nsmul interval.add_comm_monoid, nsmul_zero' := _, nsmul_succ' := _, neg := has_neg.neg interval.has_neg, sub := has_sub.sub interval.has_sub, sub_eq_add_neg := _, zsmul := subtraction_monoid.zsmul._default add_comm_monoid.add interval.subtraction_comm_monoid._proof_8 add_comm_monoid.zero interval.subtraction_comm_monoid._proof_9 interval.subtraction_comm_monoid._proof_10 add_comm_monoid.nsmul interval.subtraction_comm_monoid._proof_11 interval.subtraction_comm_monoid._proof_12 has_neg.neg, zsmul_zero' := _, zsmul_succ' := _, zsmul_neg' := _, neg_neg := _, neg_add_rev := _, neg_eq_of_add := _, add_comm := _}
Equations
- interval.division_comm_monoid = {mul := comm_monoid.mul interval.comm_monoid, mul_assoc := _, one := comm_monoid.one interval.comm_monoid, one_mul := _, mul_one := _, npow := comm_monoid.npow interval.comm_monoid, npow_zero' := _, npow_succ' := _, inv := has_inv.inv interval.has_inv, div := has_div.div interval.has_div, div_eq_mul_inv := _, zpow := division_monoid.zpow._default comm_monoid.mul interval.division_comm_monoid._proof_7 comm_monoid.one interval.division_comm_monoid._proof_8 interval.division_comm_monoid._proof_9 comm_monoid.npow interval.division_comm_monoid._proof_10 interval.division_comm_monoid._proof_11 has_inv.inv, zpow_zero' := _, zpow_succ' := _, zpow_neg' := _, inv_inv := _, mul_inv_rev := _, inv_eq_of_mul := _, mul_comm := _}
The length of an interval is its first component minus its second component. This measures the accuracy of the approximation by an interval.