0
data Even: Nat -> Type where
  EvenZ: Even Z
  EvenS: Even n -> Even (n + 2)

total
lemma1: Even Z
lemma1 = EvenZ

-- total
-- lemma2: Even Z
-- lemma2 impossible -- Idris says 'lemma2 is a valid case' and I agree with you

total
lemma3: Even 2
lemma3 = EvenS EvenZ

total
lemma4: Even 2 -> Void
lemma4 x impossible -- what does it work?

total
lemma5: Even 1 -> Void
lemma5 x impossible

I wrote some proofs on Even.

lemma1, lemma2 and lemma3 are ok, but lemma4 looks strange to me. AFAIK, both lemma3 and lemma4 can not be provable at the same time. I expected impossible keyword in lemma4 not to work and expected Idris to show me some error messages about the wrong usage of impossible.

Is impossible an unsafe keyword that can be used to assert to type checker?

worudso
  • 45
  • 5
12412316
  • 725
  • 7
  • 17
  • 3
    `impossible` should be safe, thus this is simply a bug you might want to report (though most work now is spent on Idris 2.0). A usual workaround to `impossible` problems is to case split `x` first and then try to make the cases impossible (which would report that `lemma4 (EvenS _) is a valid case`). – xash Feb 13 '20 at 16:07
  • Interestingly, when you give `lemma5` the same treatment, you **also** get that error message. :/ – Julian Kniephoff Feb 21 '20 at 07:13

0 Answers0