I am trying to prove, what to my mind is a reasonable theorem:
theorem1 : (n : Nat) -> (m : Nat) -> (n + (m - n)) = m
Proof by induction gets to the point where me need to prove this:
lemma1 : (n : Nat) -> (n - 0) = n
This is what happens when I try to prove it (the lemma, for simplicity sake) using the interactive prover:
---------- Goal: ----------
{hole0} : (n : Nat) -> minus n 0 = n
> intros
---------- Other goals: ----------
{hole0}
---------- Assumptions: ----------
n : Nat
---------- Goal: ----------
{hole1} : minus n 0 = n
> trivial
Can't unify
n = n
with
minus n 0 = n
Specifically:
Can't unify
n
with
minus n 0
I felt like I must be missing something about the definition of minus, so I looked it up in the source:
||| Subtract natural numbers. If the second number is larger than the first, return 0.
total minus : Nat -> Nat -> Nat
minus Z right = Z
minus left Z = left
minus (S left) (S right) = minus left right
The definition I need is right there! minus left Z = left
. My understanding was that Idris should just replace minus m 0
with m
here, and this is then reflexively true. What have I missed?
0
andZ
always treated as synonymous or is there something required there to make it work? – Damien_The_UnbelieverNat
is a member of theNum
class, which one of the functions isfromInteger
. AndfromInteger 0 = Z
. (There is also some special casing for Nat that goes on in the language itself and in the terminal I think.) In short I don't think that is the problem, although I am not certain enough to be entirely sure. – Vic Smith