Zulip Chat Archive

Stream: new members

Topic: primes


Alex Zhang (Jun 02 2021 at 07:15):

How can I close the second example? (it is a little bit weird to me that norm_num doesn't work for the second one...)

import data.set.lattice
import data.nat.prime

open set nat

def primes : set  := {x | prime x}

example : prime 2 :=
begin
  norm_num,
end

example : 2  primes :=
begin
   sorry
end

Kevin Buzzard (Jun 02 2021 at 07:24):

norm_num won't unfold the definition of primes for you so it can't make any progress

Kevin Buzzard (Jun 02 2021 at 07:25):

It's not its job to unfold things and it sticks to its job

Johan Commelin (Jun 02 2021 at 07:30):

maybe norm_num [primes] works.

Alex Zhang (Jun 02 2021 at 13:59):

Johan Commelin said:

maybe norm_num [primes] works.

Sadly, it wouldn't work. What can I do to close the goal then?

Eric Wieser (Jun 02 2021 at 14:00):

simp [primes], norm_num should work

Kevin Buzzard (Jun 02 2021 at 14:02):

or you can unfold primes (which does simp [primes] under the hood)

Mario Carneiro (Jun 02 2021 at 14:03):

actually just unfold primes won't be enough since you also need to cancel the mem and set_of

Mario Carneiro (Jun 02 2021 at 14:04):

although norm_num will probably do this since it uses the default simp set iirc

Mario Carneiro (Jun 02 2021 at 14:05):

by the way simp [primes] has an informative error message:

ambiguous overload, possible interpretations
    primes
    nat.primes

Mario Carneiro (Jun 02 2021 at 14:06):

norm_num [_root_.primes] works

Alex Zhang (Jun 02 2021 at 14:08):

It does work!

Alex Zhang (Jun 02 2021 at 14:08):

(deleted)

Mario Carneiro (Jun 02 2021 at 14:09):

It should work here and it usually makes some kind of progress.

Mario Carneiro (Jun 02 2021 at 14:09):

you will need to be more specific

Mario Carneiro (Jun 02 2021 at 14:10):

I don't recommend open nat because it has a tendency to cause name conflicts

Mario Carneiro (Jun 02 2021 at 14:10):

although I guess in this case it's due to your own definition overlapping with nat's

Alex Zhang (Jun 02 2021 at 14:12):

Could you explain what does _root_ mean in _root_.primes?

Johan Commelin (Jun 02 2021 at 14:12):

do_not_auto_insert_a_namespace.primes

Mario Carneiro (Jun 02 2021 at 14:13):

it is being used here to disambiguate between the absolute path primes and nat.primes since with open nat the unqualified primes could refer to either of them

Mario Carneiro (Jun 02 2021 at 14:14):

think of it like /primes vs /nat/primes instead of primes as a path


Last updated: Dec 20 2023 at 11:08 UTC