Zulip Chat Archive
Stream: iris-lean
Topic: Universe bug in product CMRA?
Markus de Medeiros (Jun 23 2025 at 21:19):
I'm trying to track down a universe bug that seems to arise when I use operations from the product CMRA. I've collected examples here.
Examples
The errors look like
stuck at solving universe constraint
max ?u.15227 ?u.15228 =?= max ?u.15223 ?u.15224
while trying to unify
Type (max ?u.15227 ?u.15228) : Type ((max ?u.15227 ?u.15228) + 1)
with
Type (max ?u.15223 ?u.15224) : Type ((max ?u.15223 ?u.15224) + 1)
which maybe suggests that it's the two branches of the product having different universe levels, but I'm not sure how to trace where the universe variables come from.
@suhr Did you encounter anything like this when you were initially implementing the product CMRA?
Mario Carneiro (Jun 23 2025 at 21:29):
Are α and A supposed to be related to each other?
Mario Carneiro (Jun 23 2025 at 21:32):
the issue is this instance:
#check cmraProd
-- Iris.cmraProd.{u_1, u_2} {α β : Type (max u_1 u_2)} [CMRA α] [CMRA β] : CMRA (α × β)
Mario Carneiro (Jun 23 2025 at 21:33):
note that the two inputs are not in general universes, so this results in an unsolvable unification problem to make α and β have the same universe and to determine u_1 and u_2 from their common level
Mario Carneiro (Jun 23 2025 at 21:39):
and the reason for that is because of this use of monad bind:
pcore x := do
let a <- CMRA.pcore x.fst
let b <- CMRA.pcore x.snd
return (a,b)
This forces the two calls to CMRA.pcore to live in the same universe. You should use Option.bind directly instead, which is more universe polymorphic than the Bind instance:
pcore x :=
(CMRA.pcore x.fst).bind fun a =>
(CMRA.pcore x.snd).bind fun b =>
return (a,b)
Markus de Medeiros (Jun 23 2025 at 21:41):
Nice, thanks! I don't think I would have ever guessed that.
Last updated: Dec 20 2025 at 21:32 UTC