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

With-clause doesn't take advantage of ruled out patterns to normalise #140

Open
ohad opened this issue Oct 26, 2019 · 1 comment
Open

With-clause doesn't take advantage of ruled out patterns to normalise #140

ohad opened this issue Oct 26, 2019 · 1 comment

Comments

@ohad
Copy link

ohad commented Oct 26, 2019

I'm not sure this is really a language problem, maybe a feature request?
Potentially related to #139.
Also, the example below is not realistic (because of the go_figure hole), it's just there to illustrate the problem in a short example.

Steps to Reproduce

Foo.idr

foo : Nat -> Bool
foo n = case compare n Z of
          LT => False
          _  => True
          
foo_true : (n : Nat) -> foo n = True
foo_true  n with (compare n Z)
 foo_true n | LT = ?go_figure  -- That's fine
 foo_true n | _  = ?hole       -- That's not

Expected Behavior

$ idris2 Foo.idr
Foo> :t hole
   n : Nat
-------------------------------------
hole : True = True

Observed Behavior

   n : Nat
-------------------------------------
hole : (case _ of { LT => False ; _ => True }) = True

We can, of course, prove the foo_true lemma (modulo go_figure) by exhausting all the other cases:

foo_true' : (n : Nat) -> foo n = True
foo_true'  n with (compare n Z)
 foo_true' n | LT = ?go_figure' -- That's fine
 foo_true' n | GT = Refl         
 foo_true' n | EQ = Refl

But it would be nicer to follow the same pattern that execution takes.

@edwinb
Copy link
Owner

edwinb commented Dec 7, 2019

This'd be nice, but would require the normaliser to keep track of a lot of information. I think this is a feature request that's very unlikely to get done, unfortunately. I've added a label, just in case anyone is enthusiastic enough to do it, but my feeling is that it'd be very complicated to achieve.

(My feeling on this sort of thing is often wrong though, so who knows...)

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

No branches or pull requests

2 participants