Zulip Chat Archive

Stream: lean4

Topic: Lemmas for functions


Julien Marquet (May 15 2021 at 16:57):

I couldn't find these lemmas in lean4, are there somewhere ?

 {α β} (f : α  β) {a b : α}, a = b  f a = f b
 {α β} {f g : α  β}, f = g   a, f a = g a

Sebastian Ullrich (May 15 2021 at 16:59):

congrArg/congrFun

Julien Marquet (May 15 2021 at 17:02):

(Oh, I understand why I didn't find them, I was expecting a f a = f b notation but they are written with Eq. Thanks !)

Kevin Buzzard (May 15 2021 at 18:58):

A lot of lean 4 core stuff is written without notation. Is there a reason for this?

Daniel Selsam (May 15 2021 at 19:02):

I presume it is a staging issue -- defining the notations (e.g. in Init/Notation.Lean) depends on many things from Init/Prelude.lean. AFAICT only Prelude.lean cannot use the notations defined in Notation.lean.

Julien Marquet (May 15 2021 at 19:29):

By the way, is there a theorem for beta reduction ?
(I noticed that simp only [] already does beta reductions)

Julien Marquet (May 15 2021 at 19:32):

(I sometimes want to rewrite in expressions like (fun x => a * x) y, but I have to beta-reduce first)

Daniel Selsam (May 15 2021 at 19:35):

beta reduction is builtin to the logic of Lean, and simp beta-reduces automatically without needing justification (since the result is def-eq to the original term).

Daniel Selsam (May 15 2021 at 19:36):

you can disable this though, if you don't want simp to beta-reduce

Daniel Selsam (May 15 2021 at 19:38):

These are the simp flags: https://github.com/leanprover/lean4/blob/master/src/Init/Meta.lean#L870-L880

Julien Marquet (May 15 2021 at 20:04):

By looking further where you pointed I also found more useful features of simp so thanks ! :)

Sebastian Ullrich (May 16 2021 at 07:29):

There is also a brief, non-exhaustive list of simp features at https://raw.githubusercontent.com/IPDSnelting/tba-2021/master/slides/lecture4.pdf?page=12, pages 12 ff

Mario Carneiro (May 16 2021 at 10:26):

Daniel Selsam said:

I presume it is a staging issue -- defining the notations (e.g. in Init/Notation.Lean) depends on many things from Init/Prelude.lean. AFAICT only Prelude.lean cannot use the notations defined in Notation.lean.

I thought it was a remnant of earlier versions of lean 4 without the stage0 stuff. With it, I don't see why notations can't be introduced immediately after the definition itself, similar to how it is done in lean 3

Sebastian Ullrich (May 16 2021 at 10:29):

These notations are not built-in, so they are taken from the current stage, so they can be defined only after ParserDescr/Macro.

Mario Carneiro (May 16 2021 at 10:47):

Does writing infixl "foo" => bar require ParserDescr to exist in the current stage? It doesn't directly reference this constant and doesn't require import Lean so I'm not sure how that happens

Sebastian Ullrich (May 16 2021 at 13:04):

It does elaborate to a ParserDescr (which is defined in Prelude)


Last updated: Dec 20 2023 at 11:08 UTC