Zulip Chat Archive

Stream: lean4

Topic: defining notations and structures simultaneously


Jason Gross (Mar 10 2021 at 20:36):

Is there a way to do something like

structure Cat where
  Obj : Type
  Hom : Obj  Obj  Type
  infix " ~> " => Hom
  id :  {a}, a ~> a

?

Sebastian Ullrich (Mar 10 2021 at 20:46):

There was in Lean 3, but not yet in Lean 4. However, there is a workaround:

section
set_option hygiene false
local infix " ~> " => Hom

structure Cat where
  Obj : Type
  Hom : Obj  Obj  Type
  id :  {a}, a ~> a
end

infix " ~> " => Cat.Hom
#check fun a b => a ~> b

Last updated: Dec 20 2023 at 11:08 UTC