Zulip Chat Archive

Stream: new members

Topic: Using a forall hypothesis


JK (Sep 01 2025 at 14:32):

I am not sure why the first proof works and the second doesn't:

import Mathlib
example {a : } (h :  b : , a  -3 + 4 * b - b ^ 2) : a  -3 + 4*2 - 2^2 := by
  exact h 2

example {n : } (hn :  m, 1  m  m  5  m  n) : 1  3  3  5  3  n := by
  exact hn 3

How can I start the proof in the second case?

Weiyi Wang (Sep 01 2025 at 14:35):

it is type annotation problem. You need to annotate m as \Z, otherwise it is inferred as Nat

JK (Sep 01 2025 at 14:36):

That doesn't solve it for me; the following still fails

import Mathlib
example {n : } (hn :  m:, 1  m  m  5  m  n) : 1  3  3  5  3  n := by
  exact hn 3

Chris Bailey (Sep 01 2025 at 14:37):

example {n : } (hn :  m, 1  m  m  5  m  n) : (1 : Int)  3  (3 : Int)  5  3  n := by
  exact hn 3

The type errors are fairly helpful in this case.

Weiyi Wang (Sep 01 2025 at 14:37):

oops, I meant annotating 1

Chris Bailey (Sep 01 2025 at 14:38):

Without adding the curve ball of I think the paths for elaborating nat literals as Nat instead of something else are much more "in your face".

JK (Sep 01 2025 at 14:38):

What if I wanted to treat 1 as a Nat?

Chris Bailey (Sep 01 2025 at 14:39):

In some cases you'll need to be explicit about the types you want if you also want to use nat literals and other notation that doesn't immediately make clear what type it's working with.

JK (Sep 01 2025 at 14:39):

and why doesn't

example {n : } (hn :  m, 1  m  m  5  m  n) : 1:  3  3:  5  3  n := by
  exact hn 3

work?

JK (Sep 01 2025 at 14:40):

Oh, I see with parentheses is does work

Chris Bailey (Sep 01 2025 at 14:41):

The error message strongly suggests a parse error: unexpected token ':'; expected ':=', 'where' or '|'

Ruben Van de Velde (Sep 01 2025 at 15:48):

You need the parentheses around the type ascription

Ruben Van de Velde (Sep 01 2025 at 15:48):

They're a fundamental part of the syntax


Last updated: Dec 20 2025 at 21:32 UTC