A couple summers ago, my student Colin Phillips implemented exhaustiveness checking for Disco, following Lower your guards: a compositional pattern-match coverage checker by Graf, Peyton Jones, and Scott. So it can now do things like
Disco> f : Unit + (Bool * Nat) -> Int
Disco> f(right(False, n)) = 3
Warning: the function f is undefined for some inputs. For example:
f(left(■)) = ...
f(right(true, 0)) = ...
f(right(true, 1)) = ...
However, Disco also has
arithmetic patterns, like
f : N -> N
f(2n) = n + 1
f(2n+1) = 3
but doing coverage checking for these is tricky in general. Quick, for what values (if any) is the below (partial) function undefined?
f : N -> N
f(3n) = 0
f(1+5n) = 1
f(2n+2) = 2
f(n+12) = 3
My student
Katherine Reid was working on a library for solving this problem, via the theory of
semilinear sets, but we never quite finished incorporating it into the Disco coverage checker. Since I'm using Disco to teach again this semester, I've started working on this again. This week, I mostly just spent some time understanding the existing code and writing down a list of the reamining tasks. I'm optimistic I can get it polished up and merged before the end of the semester.
(Answer: the function is undefined for 5 and 7.)