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 inconsistency when using Inf #3345

Open
JavierGelatti opened this issue Jul 7, 2024 · 2 comments
Open

Totality checker inconsistency when using Inf #3345

JavierGelatti opened this issue Jul 7, 2024 · 2 comments

Comments

@JavierGelatti
Copy link

Problem

Sometimes the totality checker validates a function as total when it's not.
In particular, this happens when using Inf in the return type, combined with having the recursive path inside a lambda expression passed to another function.

Steps to reproduce

The following example typechecks:

total
neverReturn : Inf Void
neverReturn = ($) (\_ => neverReturn) ()

This makes it possible to prove Void:

total
boom : Void
boom = Force neverReturn

Additional notes

When Inf is not used as part of the return type of neverReturn, the behavior is correct:

total
neverReturn : Void
-- ^^^^^^^^ Correctly reports error:
-- neverReturn is not total, possibly not terminating due to recursive path Main.neverReturn
neverReturn = ($) (\_ => neverReturn) ()

The same thing happens if we inline $:

total
neverReturn : Inf Void
-- ^^^^^^^^ Correctly reports error:
-- neverReturn is not total, possibly not terminating due to recursive path Main.neverReturn
neverReturn = (\_ => neverReturn) ()

Or if we replace $ with a hole:

total
neverReturn : Inf Void
-- ^^^^^^^^ Correctly reports error:
-- neverReturn is not total, possibly not terminating due to recursive path Main.neverReturn
neverReturn = ?apply_hole (\_ => neverReturn) ()

Or if we use $ with its infix notation:

total
neverReturn : Inf Void
-- ^^^^^^^^ Correctly reports error:
-- neverReturn is not total, possibly not terminating due to recursive path Main.neverReturn
neverReturn = (\_ => neverReturn) $ ()

📝 My Idris version is Idris 2, version 0.7.0-c74f54c12.

@gallais
Copy link
Member

gallais commented Jul 7, 2024

I'd say that's a duplicate of #806

@JavierGelatti
Copy link
Author

Yeah, sounds like the same thing, plus the way Delay is auto-inserted in this case 🤔

I'm not sure about the actual rules for implicit Delays, but that could explain the differences in the behavior of the examples I included in "Additional notes".

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