Closed mariosge closed 4 months ago
The quick answer is to add one of the constraints to the type definition --
id : {k} (fin k, k > 0, 2 ^^ k == 2 * 2 ^^ (k - 1)) => [2^^k] -> [2^^k]
id x = join (split`{2,2^^(k-1)} x)
And now this type checks appropriately.
The long answer is that Cryptol's type inference engine doesn't know enough about exponentiation to know that the constraints it is suggesting are the ones you actually want. For instance, see #704 and #1381. I think your example is included in the discussion already in #704.
This kind of constraint also crops up in algorithms like the MLKEM NTT, which recursively splits a sequence in 2, works on the sub-sequences, then catenates the results. It would be good if the solver could see that 2 ^^ k == 2 * 2 ^^ (k - 1)
really is OK.
We will be addressing this issue in our next dev cycle - updates soon!
The following function definition is not accepted:
The corresponding error is:
I encountered this in version: