Zulip Chat Archive

Stream: new members

Topic: NeZero t not definitionally equivalent to t \ne 0?


JK (Aug 08 2025 at 16:11):

I am stuck with proving the following

import Mathlib

example {t:} : t=0  t  0  := by
  obtain tzero | tnzero := eq_zero_or_neZero t
  right
  exact tzero
  left

I would have thought that NeZero t was definitionally equivalent to t ≠ 0. In any case I can't find the correct lemma to apply to either get the desired hypothesis in the first place, or to claim that NeZero t → t ≠ 0

Aaron Liu (Aug 08 2025 at 16:13):

docs#neZero_iff

Aaron Liu (Aug 08 2025 at 16:13):

the lemma is docs#eq_or_ne

JK (Aug 08 2025 at 16:15):

Thanks for that, I was not able to find it using apply?

Kenny Lau (Aug 08 2025 at 19:07):

use loogle instead

JK (Aug 08 2025 at 19:18):

I have not had much luck with loogle at all, TBH

Etienne Marion (Aug 08 2025 at 19:21):

@loogle NeZero, _ ≠ 0

loogle (Aug 08 2025 at 19:21):

:search: NeZero.mk, NeZero.ne, and 72 more

Kenny Lau (Aug 08 2025 at 19:36):

@JK next time you are stuck on Loogle, tell me what you want to find and ping me, and I'll show you the correct input to Loogle.

Junyan Xu (Aug 08 2025 at 19:52):

NeZero n is a class, in particular a structure (an inductive type with a single constructor), and you always need to apply the constructor to obtain a term whose type is a structure. If h : n ≠ 0 then ⟨h⟩ is of type NeZero n.

Dan Velleman (Aug 09 2025 at 00:42):

By the way, although it's good to know about NeZero and how to use it, I wouldn't use it for this example. Here are two ways to do it that I think are more straightforward:

import Mathlib

example {t:} : t=0  t  0 := em (t=0)

example {t:} : t=0  t  0 := by
  by_cases h : t = 0
  · left
    exact h
  · right
    exact h

Note that em is the law of excluded middle.

Kenny Lau (Aug 09 2025 at 06:36):

import Mathlib

example {t : } : t = 0  t  0 :=
  if h : t = 0 then Or.inl h else Or.inr h

example {t : } : t = 0  t  0 := by
  if h : t = 0 then ?_ else ?_
  · left
    exact h
  · right
    exact h

Wuyang (Aug 09 2025 at 08:35):

@leanfinder NeZero, _ ≠ 0

leanfinder (Aug 09 2025 at 08:35):

Here’s what I found:

Wuyang (Aug 09 2025 at 08:35):

@JK You may also try leanfinder


Last updated: Dec 20 2025 at 21:32 UTC