Zulip Chat Archive

Stream: new members

Topic: What does $ mean?


Patrick Lutz (Jun 18 2020 at 01:26):

After doing some exercises on codewars and looking at the other solutions that people submitted to the problems I solved I noticed that some solutions use the symbol $. What does that symbol mean? I don't think it's explained in Theorem Proving in Lean or the other tutorials I've looked at

Jalex Stark (Jun 18 2020 at 01:28):

f $ .. is like f ( .. )

Jalex Stark (Jun 18 2020 at 01:28):

i think it's the same $ from haskell

Patrick Lutz (Jun 18 2020 at 01:28):

Oh, I see. Is there any reason to prefer one over the other?

Patrick Lutz (Jun 18 2020 at 01:29):

Or is it just to prevent build up of ('s?

Jalex Stark (Jun 18 2020 at 01:30):

right, it's just to prevent parentheses

Jalex Stark (Jun 18 2020 at 01:30):

especially ones where the two ends are far apart

Jalex Stark (Jun 18 2020 at 01:30):

for dumb reasons, $ doesn't work correctly in tactic mode

Jalex Stark (Jun 18 2020 at 01:30):

so i mostly don't use it

Patrick Lutz (Jun 18 2020 at 01:30):

What's the reason?

Jalex Stark (Jun 18 2020 at 01:31):

oh i don't know

Jalex Stark (Jun 18 2020 at 01:31):

something about special parsing used for interactive tactics or something

Patrick Lutz (Jun 18 2020 at 01:32):

I see. Thanks for answering my question btw

Jalex Stark (Jun 18 2020 at 01:32):

i tried to modify the assumption tactic to accept an optional assumption? and all hell broke loose

Jalex Stark (Jun 18 2020 at 01:33):

i think we're supposed to accept these things because they're getting fixed in lean 4 and they're not halting mathlib progress now

Shing Tak Lam (Jun 18 2020 at 03:58):

Jalex Stark said:

for dumb reasons, $ doesn't work correctly in tactic mode

https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/term.20mode.20haveI/near/198705223

Essentially, $ has a really low precedence

Kevin Buzzard (Jun 18 2020 at 06:41):

You can see for yourself what any notation like $ does with #print notation $. To understand the output in this case you will need to know a little about Pratt parsers.

Kevin Buzzard (Jun 18 2020 at 09:02):

https://xenaproject.wordpress.com/2019/01/20/a-word-on-bidmas/


Last updated: Dec 20 2023 at 11:08 UTC