Skip to content

Commit d7bdfbb

Browse files
committed
Unbundle ApproxZero and ApproxZeroIff
Our Series Approx instances downstream approximate only the germ of functions, and thus don't satisfy this.
1 parent 6a041c8 commit d7bdfbb

5 files changed

Lines changed: 15 additions & 11 deletions

File tree

Interval/Approx.lean

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export Approx (approx)
2323
/-- `0 : A` is conservative, and `0` only approximates `0` -/
2424
class ApproxZero (A R : Type) [Zero R] [Zero A] [Approx A R] where
2525
approx_zero : approx (0 : A) (0 : R)
26+
27+
/-- `0 : A` only approximates `0` -/
28+
class ApproxZeroIff (A R : Type) [Zero R] [Zero A] [Approx A R] where
2629
approx_zero_imp : ∀ (x : R), approx (0 : A) x → x = 0
2730

2831
/-- `1 : A` is conservative -/
@@ -87,20 +90,19 @@ export ApproxSMul (approx_smul)
8790

8891
attribute [simp] approx_zero approx_one
8992

90-
lemma approx_zero_iff [Approx A R] [Zero A] [Zero R] [ApproxZero A R] (x : R) :
93+
lemma approx_zero_iff [Approx A R] [Zero A] [Zero R] [ApproxZero A R] [ApproxZeroIff A R] (x : R) :
9194
approx (0 : A) x ↔ x = 0 := by
9295
constructor
93-
· apply ApproxZero.approx_zero_imp
96+
· apply ApproxZeroIff.approx_zero_imp
9497
· intro x0; rw [x0]; exact approx_zero
9598

9699
/-!
97100
## Everything approximates itself
98101
-/
99102

100103
instance : Approx R R where approx x y := x = y
101-
instance [Zero R] : ApproxZero R R where
102-
approx_zero := by simp only [approx]
103-
approx_zero_imp x a := by simp only [approx] at a; simp only [a]
104+
instance [Zero R] : ApproxZero R R where approx_zero := by simp only [approx]
105+
instance [Zero R] : ApproxZeroIff R R where approx_zero_imp x a := by rw [approx] at a; rw [a]
104106
instance [One R] : ApproxOne R R where approx_one := by simp only [approx]
105107
instance [Neg R] : ApproxNeg R R where approx_neg := by simp only [approx]; aesop
106108
instance [Add R] : ApproxAdd R R where approx_add := by simp only [approx]; aesop

Interval/Box/Basic.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ lemma smul_def {x : Interval} {z : Box} : x • z = ⟨x * z.re, x * z.im⟩ :=
122122
lemma mem_approx_iff_ext {z : ℂ} {w : Box} : approx w z ↔ approx w.re z.re ∧ approx w.im z.im := by
123123
rfl
124124

125-
instance : ApproxZero Box ℂ where
126-
approx_zero := by simp [mem_approx_iff_ext]
127-
approx_zero_imp x a := by simpa only [approx_zero_iff] using a
125+
instance : ApproxZero Box ℂ where approx_zero := by simp [mem_approx_iff_ext]
126+
instance : ApproxZeroIff Box ℂ where approx_zero_imp x a := by simpa only [approx_zero_iff] using a
128127
instance : ApproxOne Box ℂ where approx_one := by simp [mem_approx_iff_ext]
129128

130129
/-- `star` is conservative -/

Interval/Fixed.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ instance : ApproxNan (Fixed s) ℝ where
249249

250250
instance : ApproxZero (Fixed s) ℝ where
251251
approx_zero := by simp only [approx, Fixed.val_zero, or_true]
252+
253+
instance : ApproxZeroIff (Fixed s) ℝ where
252254
approx_zero_imp x a := by simpa only [Fixed.approx_zero_iff] using a
253255

254256
/-- If we're not `nan`, `approx` is a singleton -/

Interval/Floating/Basic.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ instance : ApproxNan Floating ℝ where
154154

155155
instance : ApproxZero Floating ℝ where
156156
approx_zero := by simp only [approx, val_zero, or_true]
157+
158+
instance : ApproxZeroIff Floating ℝ where
157159
approx_zero_imp x a := by simpa only [approx_zero_iff] using a
158160

159161
/-- `1 = 1` -/

Interval/Interval/Basic.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,8 @@ instance : ApproxNan Interval ℝ where
137137
approx_nan a := by simp only [approx, lo_nan, hi_nan, true_or]
138138

139139
-- Basic `approx` lemmas
140-
instance : ApproxZero Interval ℝ where
141-
approx_zero := by simp only [approx_zero]
142-
approx_zero_imp x a := by simpa only [approx_zero] using a
140+
instance : ApproxZero Interval ℝ where approx_zero := by simp only [approx_zero]
141+
instance : ApproxZeroIff Interval ℝ where approx_zero_imp x a := by simpa only [approx_zero] using a
143142
instance : ApproxOne Interval ℝ where approx_one := by simp only [approx_one]
144143

145144
/-- `x.lo = nan` if `x = nan` -/

0 commit comments

Comments
 (0)