Lifting coercions to theory refinements › Refining bundled theories [01HO]

When you have a theory, like that of semigroups, you define it in a fully unbiased/bundled way:

theory Semigroup where
  car: Set
  join: car -> car -> car
  join/assoc: (x y z : car) -> join (join x y) z = join x (join y z)

Then we might define monoids in terms of semigroups:

theory Monoid where
  inherit Semigroup

  unit: car
  join/unit/left: (x : car) -> join unit x = x
  join/unit/right: (x : car) -> join x unit = x

Suppose we want to describe the assumptions to the Eckmann–Hilton argument, where you have a pair of monoids sharing the same carrier set and satisfying a distributive law. For that, we need a way to refine a theory by a partial instantiation of its fields. Here is how it might look:

theory EckmannHilton where
  X: Set
  M, N: Monoid / {car => X}
  dist: (u v w x: X) -> M.join (N.join u v) (N.join w x) = N.mul (M.mul u w) (M.mul v x)

Things like this are dealt with in the world of Rocq’s Mathematical Components by using a “mixin” pattern: for every structure you predict in advance what unbundlings you are going to need, and then define a bundled version by taking a sum over these. This works very well, though it is a bit cumbersome and inflexible. I would like to build this feature directly into the language, and do it in such a way that you don’t need to predict unbundlings in advance.