Zulip Chat Archive

Stream: general

Topic: partrec_code


Yury G. Kudryashov (May 01 2020 at 05:19):

Is def nat.partrec.code.eval slow for everyone or just me? The definition times out in with -T100000

Yury G. Kudryashov (May 01 2020 at 05:22):

I'm trying to fix compile failures in #2579 coming from mid-proof simps simplifying more than expected.

Mario Carneiro (May 01 2020 at 05:26):

If I remember the theorem you are talking about, it was slow but not that slow when I wrote it

Mario Carneiro (May 01 2020 at 05:26):

Oh, it's just the definition?

Mario Carneiro (May 01 2020 at 05:26):

there is nothing at all expensive in the definition

Mario Carneiro (May 01 2020 at 05:27):

I thought you were talking about rec_computable

Yury G. Kudryashov (May 01 2020 at 05:28):

Try to compile it in master...

Yury G. Kudryashov (May 01 2020 at 05:29):

It's hard for me to fix this because I don't understand what is happening in this file.

Mario Carneiro (May 01 2020 at 05:30):

parsing took 1.4ms
elaboration of eval took 1s
type checking of eval took 0.0133ms
decl post-processing of eval took 6.22ms

on d84de80 (12 Apr)

Yury G. Kudryashov (May 01 2020 at 05:32):

/me is downloading .oleans for this revision

Mario Carneiro (May 01 2020 at 05:32):

Confirmed timeout on master

Mario Carneiro (May 01 2020 at 05:33):

There is nothing at all remarkable about the definition. It's a recursion over the simple inductive type code, and there are no complicated elaboration problems in it

Yury G. Kudryashov (May 01 2020 at 05:33):

I'll git bisect this and come back later.

Bryan Gin-ge Chen (May 01 2020 at 05:36):

Is #2573 related?

Mario Carneiro (May 01 2020 at 05:36):

#check show  →. , from λ n, n.unpair.1

this is slow

Mario Carneiro (May 01 2020 at 05:37):

aha, it's using the coercion to roption

Mario Carneiro (May 01 2020 at 05:37):

#check show  →. , from λ n, roption.some (n.unpair.1)

is fine

Mario Carneiro (May 01 2020 at 05:38):

#check λ n:, (n : roption ) -- also slow

Mario Carneiro (May 01 2020 at 05:39):

oh, there is no coercion to roption anymore

Mario Carneiro (May 01 2020 at 05:44):

Oh, there never was. There is a coercion from A -> B to A ->. B but the roption version of that doesn't exist because these instances don't compose:

instance : has_coe (option α) (roption α) := of_option
instance coe_option {a : Type u} : has_coe_t a (option a) :=
⟨λ x, some x

Mario Carneiro (May 01 2020 at 05:47):

#check ((λ n:, n :   ) :  →. ) -- fast
#check (λ n:, n :  →. ) -- slow

Mario Carneiro (May 01 2020 at 05:47):

Apparently the order of operations has changed here, or there is a missing fallback or something

Mario Carneiro (May 01 2020 at 05:48):

I think it tries to coerce nat to roption nat inside the lambda instead of coercing the function types

Mario Carneiro (May 01 2020 at 05:49):

anyway, if you are in the middle of a refactor @Yury G. Kudryashov I would suggest changing those lines to

| left         := λ n, roption.some (n.unpair.1)
| right        := λ n, roption.some (n.unpair.2)

and everything else seems to still work.

Yury G. Kudryashov (May 01 2020 at 05:50):

Thank you.

Mario Carneiro (May 01 2020 at 05:50):

I think the coercion was kind of a bad idea anyway

Yury G. Kudryashov (May 01 2020 at 05:54):

↑(λ n : ℕ, n.unpair.1) is fast too

Gabriel Ebner (May 01 2020 at 06:12):

I noticed this slowness yesterday as well. I think there is a general problem with the coercion from integers to arbitrary rings see #2573. Unfortunately my PR seems to time out somewhere.

Yury G. Kudryashov (May 01 2020 at 06:24):

The first "bad" commit is ffb99a338

Yury G. Kudryashov (May 01 2020 at 06:25):

#2363

Yury G. Kudryashov (May 01 2020 at 06:25):

I have no idea why it slows down elaboration in partrec_code.

Yury G. Kudryashov (May 01 2020 at 06:25):

But in the previous commit the elaboration is much faster.

Yury G. Kudryashov (May 01 2020 at 06:30):

BTW, with an explicit ↑(λ n : ℕ, n.unpair.1) it is 10x faster than before #2363 (and 100x faster than after #2363).

Yury G. Kudryashov (May 01 2020 at 06:32):

@Gabriel Ebner Compile failed in a simp lemma in data.int.basic. I don't know why it timed out instead of failing.

Yury G. Kudryashov (May 01 2020 at 06:41):

But the whole file is still very slow compared to what we had before #2363


Last updated: Dec 20 2023 at 11:08 UTC