3

I've asked a question about Idris' way of type checking universes. Now I'm trying out some example that would cause universe inconsistency. Here is the easiest one I could come up with

foo : Type
foo = Type

bar : Main.foo
bar = Main.foo

The output error is:

test.idr:2:5:Universe inconsistency.
        Working on: z
        Old domain: (4,4)
        New domain: (4,3)
        Involved constraints: 
                ConstraintFC {uconstraint = z <= w, ufc = test.idr:2:5}
                ConstraintFC {uconstraint = y < z, ufc = test.idr:2:5}
                ConstraintFC {uconstraint = z <= w, ufc = test.idr:2:5}

Other than the above example, are there any more real examples that cause universe inconsistency? Why are they inconsistent?

Community
  • 1
  • 1
盛安安
  • 1,110
  • 1
  • 8
  • 21

5 Answers5

4

There's this one from the test suite:

https://github.com/idris-lang/Idris-dev/blob/master/test/universes002/universes002.idr

I think it's quite hard to do this sort of thing by accident though :).

Edwin Brady
  • 4,546
  • 1
  • 22
  • 14
1

What I can think of is the Girard's paradox, which causes universe inconsistency. However, I can't think of any real world example that utilizes universe inconsistency atm.

0

One I came up with during one of my durp moments was

equalTypesCommute -> x=y -> (x=y)=(y=x)
equalTypesCommute Refl = Refl

This, of course, blows up :)

Ben Kushigian
  • 285
  • 1
  • 10
0

I just stumbled upon this. It's quite a natural definition, so it's really surprising.

Subset : Type -> Type
Subset a = a -> Type

Family : Type -> Type
Family a = Subset (Subset a)

familyIntersection : Family a -> Subset a
familyIntersection {a} f x = (u : Subset a) -> f u -> u x

This gives the output (for idris --check):

test.idr:2:12-20:
  |
2 | Subset a = a -> Type
  |            ~~~~~~~~~
Universe inconsistency.
        Working on: ./test.idr.l1
        Old domain: (4,4)
        New domain: (4,3)
        Involved constraints: 
                ConstraintFC {uconstraint = ./test.idr.l1 < ./test.idr.m1, ufc = test.idr:2:12-20}
                ConstraintFC {uconstraint = ./test.idr.l1 < ./test.idr.m1, ufc = test.idr:2:12-20}
                ConstraintFC {uconstraint = ./test.idr.v2 <= ./test.idr.l1, ufc = test.idr:8:30-57}

For anyone not familiar, that's a basic definition from set theory translated (in the most natural way, in my opinion) to Idris: an element is in the intersection of a family of subsets if it is in all of them. In other words, an element is in the intersection if, for every subset of the base type, if the subset is in the family, the element is in the subset.

0

Found this by accident. If you omit the {ty: Type} -> it complains about universe inconsistency. Not sure that it's not a compiler bug though.

codata Conat = Z | S Conat

codata Covect : (len : Conat) -> ty -> Type where
  (::) :  ty -> Covect len ty -> Covect (S len) ty
  Nil  :  {ty: Type} -> Covect Z ty
  -- Nil  :  Covect Z ty       -- for some reason this messes with the universe 

stripe : Covect len (Covect len t) -> Covect len (List ty)
stripe [] = []
Saintali
  • 4,482
  • 2
  • 29
  • 49