I am trying to write a declaration of two mutually inductive datatypes that both take a type parameter as arguments as follows:
noeq
type foo 'a =
| FooA: x: 'a -> foo 'a
| Foob: y: bar 'a -> foo 'a
and bar 'b =
| BarA: x: int -> bar 'b
| BarF: y: foo 'b -> bar 'b
I get an error message that is as follows:
LabeledStates.fst(59,0-64,31): (Error 67) Failed to solve universe inequalities for inductives 1 error was reported (see above)
(where line 59 is the line that includes "type foo 'a")
What does this error mean and what can I do to fix it?
If I remove the type parameters (and give foo.x the type of int, for example) I do not get errors anymore. Similarly, if I just give one of the types a type parameter but not the other, I also do not have errors.
F* isn't capable of inferring universes in cases like this. You can provide explicit universe instantiations, however. For example, here are three possible solutions:
First, a doubly universe polymorphic one, most general but also possibly quite cumbersome to use
A singly universe polymorphic solution, perhaps a bit simpler, though less general:
And, finally, a version specialized to universe 0, probably the easiest to use if it fits your needs, but also least general: