Approximate arithmetic typeclasses #
class
ApproxRing
(A R : Type)
[Ring R]
extends ApproxAddGroup A R, One A, Mul A, ApproxOne A R, ApproxMul A R :
A approximates the ring R
- zero : A
- neg : A → A
- add : A → A → A
- sub : A → A → A
- approx_zero : approx 0 0
- one : A
- mul : A → A → A
- approx_one : approx 1 1
Instances
theorem
approx_zero_iff
{R A : Type}
[Approx A R]
[Zero A]
[Zero R]
[ApproxZero A R]
[ApproxZeroIff A R]
(x : R)
:
Everything approximates itself #
Equations
- instApprox = { approx := fun (x y : R) => x = y }
Rounding utilities #
For when we approximately round up or down.
@[simp]
theorem
rounds_nan
{A I : Type}
[LinearOrder I]
{up : Bool}
[Approx A I]
[Nan A]
[ApproxNan A I]
{y : I}
:
theorem
rounds_neg
{A I : Type}
[LinearOrder I]
{up : Bool}
[Approx A I]
[Neg A]
[AddGroup I]
[ApproxNeg A I]
[AddLeftMono I]
[AddRightMono I]
{x : A}
{y : I}
(a : Rounds x (-y) !up)
:
theorem
Rounds.neg
{A I : Type}
[LinearOrder I]
{up : Bool}
[Approx A I]
[Neg A]
[AddGroup I]
[ApproxNeg A I]
[AddLeftMono I]
[AddRightMono I]
{x : A}
{y : I}
(a : Rounds x y !up)
: