Zulip Chat Archive

Stream: Is there code for X?

Topic: For all statement to function


Timothy Harevy (Feb 07 2024 at 11:42):

Is there a code for if I have

nN,ynx\forall n \in \mathbb{N},y*n\le x

is there a way I can view a for-all statement as a function of n that is bounded above by x

Riccardo Brasca (Feb 07 2024 at 11:49):

Can you be a little more precise? Do you want to write in lean this statement?

Yakov Pechersky (Feb 07 2024 at 12:09):

My guess is the value Sup (Set.range (. * n))

Timothy Harevy (Feb 07 2024 at 12:13):

I have a statement that says for all n, yn is less than equal to x I want to change that in LEAN to the function yn that is bounded above by x

Kevin Buzzard (Feb 07 2024 at 12:21):

Can you write the lean code for what you have and what you want, rather than just writing mathematics? There are many lean implementations of one mathematical specification.

Timothy Harevy (Feb 07 2024 at 13:31):

I have shown this

have h :  (n : ), x  y * n

And want to know of it is possible to change this statement into the form

is_upper_bound (fun n  y*n) x

Riccardo Brasca (Feb 07 2024 at 13:34):

Can you write a #mwe? is_upper_bound does not exist in mathlib.

Timothy Harevy (Feb 07 2024 at 13:36):

I've defined it as such

def is_upper_bound {α : Type u} [Preorder α] (A : Set α) (M:α) :=
  xA,xM

Riccardo Brasca (Feb 07 2024 at 13:37):

In this case is_upper_bound (fun n ↦ y*n) x does not make sense, since (fun n ↦ y*n) is a function, not a set.

Riccardo Brasca (Feb 07 2024 at 13:37):

(also note that we have docs#upperBounds)

Timothy Harevy (Feb 07 2024 at 13:39):

Okay thank you

Riccardo Brasca (Feb 07 2024 at 13:40):

You can of course consider the upper bound of the range of the function, that is what you want.

Riccardo Brasca (Feb 07 2024 at 13:41):

import Mathlib

universe u

def is_upper_bound {α : Type u} [Preorder α] (A : Set α) (M:α) :=
  xA,xM

example (x y : ) (h :  (n : ), x  y * n) :
    is_upper_bound (Set.range fun n  y*n) x := by
  intro a b, hb
  rw [ hb]
  exact h b

Riccardo Brasca (Feb 07 2024 at 13:45):

Or

example (x y : ) (h :  (n : ), x  y * n) :
    is_upper_bound (Set.range fun n  y*n) x :=
  fun _ b, hb  hb.symm  h b

if you like making things unreadable.

Yury G. Kudryashov (Mar 05 2024 at 16:14):

We also have docs#Set.forall_range_iff


Last updated: May 02 2025 at 03:31 UTC