Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Totality checker fails to recognize missing cases on irrelevant parameter in irrelevant function #3241

Open
Adowrath opened this issue Mar 30, 2024 · 1 comment

Comments

@Adowrath
Copy link
Contributor

total 0
unlift : (0 x : Bool) -> (x == x) = True
unlift True = Refl
-- unlift False = Refl

The totality/coverage checker fails to recognize that this definition isn't total, but only if both unlift and x are marked as irrelevant. It correctly identifies the missing coverage if x is made relevant. This works with other types, like Bits8 and a valid number, as well.

Loading the file in the REPL, and using irrelevantEq to recover a value shows the discrepancy:

> irrelevantEq (unlift True)
Refl
> irrelevantEq (unlift False)
irrelevantEq (unlift False)

Using a similar definition thanks to @gallais, is is possible to prove Void:

total 0
unlift : (0 x : Bool) -> ifThenElse x Unit Void
unlift True = ()

total
boom : Void
boom = void $ unlift False
@gallais
Copy link
Member

gallais commented Mar 30, 2024

I suspect it's due to the checker seeing the Bool is 0 and so it assumes the pattern must have been forced by another split. Except that we are in an erased context and so are allowed to split on 0s...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants