Zulip Chat Archive

Stream: new members

Topic: nonzero integer


Holly Liu (Aug 24 2021 at 01:16):

how do i get an element from a set of nonzero integers? i tried def nat_plus_0 := ℕ ∪ {0} and get the errors failed to synthesize type class instance for has_union and has_singleton

Mario Carneiro (Aug 24 2021 at 01:17):

nat already has a zero

Mario Carneiro (Aug 24 2021 at 01:17):

if you want to add another one though you should use with_zero nat

Mario Carneiro (Aug 24 2021 at 01:18):

types are not sets, they have different operators for combining them

Holly Liu (Aug 24 2021 at 01:21):

ok

Eric Wieser (Aug 24 2021 at 07:09):

Why are you asking for non-zero integers yet trying to spell "the naturals including zero"?

Holly Liu (Aug 24 2021 at 16:05):

oops i think i actually meant ℤ \ {0}

Holly Liu (Aug 24 2021 at 16:12):

so i think this is what i'm trying to do: def nonzero := ℤ \ {0} and i get failed to synthesize type class instance for has_sdiff and has_singleton

Eric Rodriguez (Aug 24 2021 at 16:22):

again, ℤ is a type, \ is an operation on sets

Eric Rodriguez (Aug 24 2021 at 16:22):

usually you'd do something like (n : ℤ) (h : n ≠ 0)

Eric Rodriguez (Aug 24 2021 at 16:23):

but you could go for (n : { x : ℤ // x ≠ 0}) too, but I'd advice against it

Holly Liu (Aug 24 2021 at 16:54):

whoops sorry

Holly Liu (Aug 24 2021 at 16:54):

thanks!


Last updated: Dec 20 2023 at 11:08 UTC