Zulip Chat Archive

Stream: general

Topic: Instance hell when implementing PROPs


finegeometer (Aug 20 2024 at 02:39):

I was trying to implement PROPs, a particular kind of monoidal category, and morphisms between them. This is what I have so far.

import Mathlib.CategoryTheory.Bicategory.SingleObj
import Mathlib.CategoryTheory.Bicategory.Strict
import Mathlib.CategoryTheory.Monoidal.Braided.Basic

-- https://ncatlab.org/nlab/show/PROP
structure PROP where
  cat : @CategoryTheory.Category 
  mon : @CategoryTheory.MonoidalCategory  cat
  symm : @CategoryTheory.SymmetricCategory  cat mon
  strict : CategoryTheory.Bicategory.Strict (@CategoryTheory.MonoidalSingleObj  cat mon)
  tensorObj_is_add : mon.tensorObj = Nat.add

structure PROP.Hom (P1 P2 : PROP) where
  functor : @CategoryTheory.BraidedFunctor
     P1.cat P1.mon
    (@CategoryTheory.SymmetricCategory.toBraidedCategory  P1.cat P1.mon P1.symm)
     P2.cat P2.mon
    (@CategoryTheory.SymmetricCategory.toBraidedCategory  P2.cat P2.mon P2.symm)
  functor_preserves_objects :
    (@Prefunctor.obj  P1.cat.toQuiver  P2.cat.toQuiver
      $ @CategoryTheory.Functor.toPrefunctor  P1.cat  P2.cat
      $ @CategoryTheory.LaxMonoidalFunctor.toFunctor  P1.cat P1.mon  P2.cat P2.mon
      $ @CategoryTheory.MonoidalFunctor.toLaxMonoidalFunctor  P1.cat P1.mon  P2.cat P2.mon
      $ @CategoryTheory.BraidedFunctor.toMonoidalFunctor
           P1.cat P1.mon (@CategoryTheory.SymmetricCategory.toBraidedCategory  P1.cat P1.mon P1.symm)
           P2.cat P2.mon (@CategoryTheory.SymmetricCategory.toBraidedCategory  P2.cat P2.mon P2.symm)
      $ functor
    ) = id

That last line, functor_preserves_objects, should be as simple as functor.obj = id.
But if I write that, Lean can't figure out the correct instances.
So I'm stuck with this nine-line mess.

Is there a way to simplify this? Alternatively, is there a better design for these definitions?

Yaël Dillies (Aug 20 2024 at 07:05):

I have already written some code about PROPs, let me dig it up


Last updated: May 02 2025 at 03:31 UTC