Zulip Chat Archive

Stream: lean4

Topic: Glitch in lean4 doc string for List


Hunter Monroe (Dec 21 2023 at 02:10):

This looks like a glitch in the doc strings of Init.Data.List in Basic.lean where it has O(|l|). You see this in any lean file if you hover over List.erase to see the doc string. No other lean file has the string O(.

`O(|l|)`. `erase l a` removes the first occurrence of `a` from `l`.

Kim Morrison (Dec 21 2023 at 02:16):

@Hunter Monroe, what do you think is the glitch? I'm not sure what you think is wrong here.

Hunter Monroe (Dec 21 2023 at 04:05):

What is O(|l|)? Is it big O notation for the time required to compute the List.erase function? For eraseDups, the doc string begins O(|l|^2), and that function requires a loop within a loop.

Hunter Monroe (Dec 21 2023 at 04:07):

Actually the doc string for List.append says "It takes time proportional to the first list." so it must be big O notation.

Hunter Monroe (Dec 21 2023 at 04:08):

I put #check List.append in a .lean file and wondered why the tooltip was giving big O notation.

Kim Morrison (Dec 21 2023 at 05:25):

Yes, it's describing the runtime of the function. If you'd like to make a PR rearranging the comment so the runtime description comes later, and is more clearly about runtime, I will merge it! :-)

Mario Carneiro (Dec 21 2023 at 06:56):

This is a pattern borrowed from the std docs which use it more heavily

Mario Carneiro (Dec 21 2023 at 06:57):

I think it is good to have information in the docstring be sorted from more compact to less compact so that skimming works


Last updated: May 02 2025 at 03:31 UTC