Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proving mem_approx for functions involving ofNat #6

Closed
adomasbaliuka opened this issue Aug 18, 2024 · 3 comments
Closed

Proving mem_approx for functions involving ofNat #6

adomasbaliuka opened this issue Aug 18, 2024 · 3 comments

Comments

@adomasbaliuka
Copy link
Contributor

adomasbaliuka commented Aug 18, 2024

How should one prove mem_approx_f below?

I don't know how to prove the sorry and also don't know how one might generalize mem_approx_ofNat to work for numbers besides 2.

import Interval

def Interval.f (x : Interval) : Interval := x / 2

noncomputable def Real.f (x : ℝ) : ℝ := x / 2

@[mono] lemma mem_approx_ofNat :
  (n : ℝ) ∈ approx (OfNat.ofNat 2 : Interval) := by
  sorry

@[mono] lemma mem_approx_f (ix : Interval) (x : ℝ) (is_approx_x : x ∈ approx ix) :
    x.f ∈ approx ix.f := by
  simp [Interval.f, Real.f]
  mono

With naive approach of adding

@[mono] lemma mem_approx_ofNat' {n : ℕ} [OfNat Interval n]:
  (n : ℝ) ∈ approx (OfNat.ofNat n : Interval) := by
  sorry

@[mono] lemma mem_approx_f (ix : Interval) (x : ℝ) (is_approx_x : x ∈ approx ix) :
    x.f ∈ approx ix.f := by
  simp [Interval.f, Real.f]
  mono
  exact mem_approx_ofNat'

mono does not pick up on it.

@girving
Copy link
Owner

girving commented Aug 19, 2024

Sorry for delay! I've updated to recent Mathlib now, and also ported my mono machinery over to a much cleaner custom approx tactic built on Aesop. The new version of your code is:

import Interval

def Interval.f (x : Interval) : Interval := x / 2

noncomputable def Real.f (x : ℝ) : ℝ := x / 2

@[mono] lemma mem_approx_f (ix : Interval) (x : ℝ) (m : x ∈ approx ix) :
    x.f ∈ approx ix.f := by
  simp only [Real.f, Interval.f]
  approx

@girving
Copy link
Owner

girving commented Aug 19, 2024

Unfortunately all the OfNat related lemmas have to be carefully marked with no_index due to leanprover/lean4#2867, but this should be all done now.

@adomasbaliuka
Copy link
Contributor Author

That works great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants