Zulip Chat Archive

Stream: new members

Topic: How to define functions from or to intervals.


Mattia Bottoni (Nov 11 2023 at 14:38):

Hi everybody :)

I want to prove statements like this in Lean 4:
Show that \R and (√2, +∞) have equal cardinality by describing a bijection from one to the other. Describe your bijection with a formula.

I already know how to show that a function is injective and surjective, but I don’t know how to define a function from \R to (√2, +∞) in Lean.
Is that possible? I want to use the function f(x) = √2 + e^x.

Thank you all in advance!

Eric Wieser (Nov 11 2023 at 14:45):

You can use ℝ → Set.Ioi (Real.sqrt 2) as the type of the function

Eric Wieser (Nov 11 2023 at 14:46):

(docs#Set.Ioi)

Ruben Van de Velde (Nov 11 2023 at 14:47):

Alternatively, write something like

import Mathlib

noncomputable def f (x : ) :  := Real.sqrt 2 + Real.exp x

example : Set.MapsTo f Set.univ (Set.Ioi <| Real.sqrt 2) := by
  sorry

Ruben Van de Velde (Nov 11 2023 at 14:48):

Or more to the point,

import Mathlib

noncomputable def f (x : ) :  := Real.sqrt 2 + Real.exp x

example : Set.BijOn f Set.univ (Set.Ioi <| Real.sqrt 2) := by
  sorry

Ruben Van de Velde (Nov 11 2023 at 15:22):

Is this missing from mathlib?

theorem C (g :    ) (s) (h : Set.SurjOn g s (Set.Ioi 0)) (a) : Set.SurjOn (a + g ·) s (Set.Ioi a) := by
  intro x hx
  have : x - a  Set.Ioi 0 := by
    simpa using hx
  simpa [eq_sub_iff_add_eq'] using h this

(can be generalized, presumably)

Yaël Dillies (Nov 11 2023 at 15:24):

This is basically just composition with a bijective function. But it's not in mathlib verbatim.

Ruben Van de Velde (Nov 11 2023 at 19:42):

Thanks for the pointer; the other function doesn't even need to be bijective (or surjective):

theorem C (g :    ) (s) (h : Set.SurjOn g s (Set.Ioi 0)) (a) : Set.SurjOn (a + g ·) s (Set.Ioi a) := by
  simpa using h.comp_left (a + ·)

Ruben Van de Velde (Nov 11 2023 at 19:46):

I'm also surprised we don't seem to have

theorem C : Set.SurjOn g Set.univ (Set.range g) := by
  intro x
  simp only [Set.image_univ, imp_self]

Yaël Dillies (Nov 11 2023 at 19:47):

It's a corollary of docs#Set.surjOn_image

Ruben Van de Velde (Nov 11 2023 at 19:51):

Thanks again, Yaëlsearch :)

Mattia Bottoni (Nov 12 2023 at 12:06):

Thank you all for your efforts :)


Last updated: Dec 20 2023 at 11:08 UTC