Zulip Chat Archive

Stream: new members

Topic: Cannot infer {a b} from f a ≤ f b when f 1 ≤ f 0


attoknot (Jan 11 2026 at 09:53):

Hi. For some reason lean cannot infer a and b in this case. Does anyone have more information on this behaviour?

example : ¬∀ {f :   }, Monotone f   {a b}, f a  f b  a  b := by
  intro h
  let f :    := fun x => 0
  have monof : Monotone f := fun _ _ _ => by rfl
  have h' : f 1  f 0 := le_refl _
  #check h monof h'         /- h monof h' : ?m.45 ≤ ?m.46 -/
  #check @h _ monof 1 _ h'  /- h monof h' : 1 ≤ ?m.47 -/
  #check @h _ monof 1 0 h'  /- h monof h' : 1 ≤ 0 -/

(this is from the "Mathematics in Lean" book)

attoknot (Jan 11 2026 at 09:56):

it works when f is opaque

attoknot (Jan 11 2026 at 09:59):

this makes sense. lean probably can't match f 0 := 0 against f ?. we can't always have nice things. though, it is annoying that annotating the return type isn't enough and I have to give a and b explicitly

Bbbbbbbbba (Jan 11 2026 at 11:12):

I guess it still works as long as you can match it to your goal?

import Mathlib

example : ¬∀ {f :   }, Monotone f   {a b}, f a  f b  a  b := by
  intro h
  let f :    := fun x => 0
  have monof : Monotone f := fun _ _ _ => by rfl
  have h' : f 1  f 0 := le_refl _
  suffices (1 : )  0 from by lia
  exact h monof h'

Bbbbbbbbba (Jan 11 2026 at 12:15):

Incidentally this is much easier with push_neg:

import Mathlib

example : ¬∀ {f :   }, Monotone f   {a b}, f a  f b  a  b := by
  push_neg
  exact fun x => 0, fun _ _ _ => by rfl, 1, 0, by rfl, Real.zero_lt_one

attoknot (Jan 11 2026 at 12:21):

thanks. turns out it was my fault that return type annotations weren't working. it works if I do

  have : (1 : )  0 := h monof h'

instead of 1 ≤ 0. polymorphic literals do require time to get used to...


Last updated: Feb 28 2026 at 14:05 UTC