Zulip Chat Archive

Stream: lean4

Topic: defining notations and structures simultaneously


view this post on Zulip 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

?

view this post on Zulip 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: May 07 2021 at 13:21 UTC