Zulip Chat Archive

Stream: general

Topic: Applying (λ x, x + b) and (+ b) give different expressions


Eric Wieser (Apr 18 2021 at 13:25):

I'm seeing some odd behavior where(λ x, x + b) and (+ b) have the same pretty-printed representation, yet behave differently under function application

variables {a b : } {s : set }

-- same
#check (λ _x, _x + b) -- λ (_x : ℕ), _x + b : ℕ → ℕ
#check (+ b)          -- λ (_x : ℕ), _x + b : ℕ → ℕ

-- different?
#check (λ x, x + b) a -- (λ (x : ℕ), x + b) a : ℕ
#check ((+ b) : _) a  -- (λ (x : ℕ), x + b) a : ℕ
#check (+ b) a        -- a + b : ℕ

What's going on here?

Bhavik Mehta (Apr 18 2021 at 13:48):

Aren't these definitionally the same thing?

Eric Rodriguez (Apr 18 2021 at 13:56):

i was gonna say it was just b-red, but pp.beta causes even more confusion:

set_option pp.beta true

-- different?
#check (λ x, x + b) a -- a + b : ℕ
#check ((+ b) : _) a  -- (λ (_x : ℕ), _x + b) a : ℕ
#check (+ b) a        -- a + b : ℕ

Eric Wieser (Apr 18 2021 at 14:01):

Yes, they're all defeq, but I need syntactic equality to make the elaborator behave

Mario Carneiro (Apr 18 2021 at 23:20):

Don't use set_option pp.beta true, it performs beta reduction in the pretty printer which makes it hard to tell what term you are actually looking at

Mario Carneiro (Apr 18 2021 at 23:22):

I would guess that this is parser magic, it sees that you have applied a function slice operator to some arguments and pre-composes it

Eric Rodriguez (Apr 18 2021 at 23:24):

Mario Carneiro said:

Don't use set_option pp.beta true, it performs beta reduction in the pretty printer which makes it hard to tell what term you are actually looking at

why is β-red in the pretty printer bad? I've got a lot of λs flying about so they make my proofs a lot easier

Mario Carneiro (Apr 18 2021 at 23:33):

because they aren't making your proofs easier, they are making your proofs look easier

Mario Carneiro (Apr 18 2021 at 23:33):

it doesn't do anything at all to the state

Mario Carneiro (Apr 18 2021 at 23:34):

if you want to do beta reduction use dsimp only

Mario Carneiro (Apr 18 2021 at 23:34):

if you want to pretend beta reduction doesn't exist then use pp.beta

Mario Carneiro (Apr 18 2021 at 23:35):

but then you will get weird errors when on identical (looking!) states rw will work in one case and fail in the other

Eric Rodriguez (Apr 18 2021 at 23:40):

wow, surprised that hasn't bit me yet. turned it off; thanks!


Last updated: Dec 20 2023 at 11:08 UTC