-
Notifications
You must be signed in to change notification settings - Fork 642
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 issue when inductive data-type use is in a parameter of another data-type #3661
Comments
I translated the above mutual inductive definition into a type family and can confirm that the totality checker doesn't see the data FS : (switch : Bool) -> Type where
FirstSimple : FS False
FirstSecond : FS True -> FS False
SecondSimple : FS True
SecondFirst : List (FS False) -> FS True
calculate : FS b -> Nat
calculate FirstSimple = 1
calculate (FirstSecond x) = calculate x
calculate SecondSimple = 2
calculate (SecondFirst xs) = sum $ map calculate xs |
Thanks for the bug report! I think I will tag this as real bug since I do not see any major reason why this should not work. |
It's because of the 'List' - the positivity check in Idris doesn't allow this because it only allows recursive arguments if they are either direct uses of the type, or the return type of a higher order function. There's no reason not to allow this, it just needs implementing. |
Oh, and the other issue is that 'calculate' is used as an argument to a higher order function, and the totality checker can't immediately see that this is valid. This is much harder to do anything about. I don't know how Coq manages to spot that this is okay... I suppose I'll have to read up on how their totality checker works these days. |
Idris totality checker thinks the function
calculate
is not total, however if I change the last line usingfoldl
:Idris assumes
calculate
is total, what's the reason. Could you explain is it a bug or expected behaviour?The text was updated successfully, but these errors were encountered: