I'm in Coq trying to prove that
Theorem evenb_n__oddb_Sn : ∀n : nat,
evenb n = negb (evenb (S n)).
I'm using induction on n
. The base case is trivial, so I'm at the inductive case and my goal looks like:
k : nat
IHk : evenb k = negb (evenb (S k))
============================
evenb (S k) = negb (evenb (S (S k)))
Now of course there's a fundamental axiom of functions that asserts
a = b -> f a = f b
For all functions f : A -> B
. So I could apply negb
to both sides, which would give me
k : nat
IHk : evenb k = negb (evenb (S k))
============================
negb (evenb (S k)) = negb (negb (evenb (S (S k))))
Which would let me use my inductive hypothesis from right to left, the negations on the right would cancel each other out, and the defintion of evenb
would complete the proof.
Now, there might be a better way to prove this particular theorem (edit: there is, I did it another way), but as this in general seems like a useful thing to do, what's the way to modify an equality goal in Coq by applying a function to both sides?
Note: I realize that this wouldn't work for any arbitrary function: for example, you could use it to prove that -1 = 1
by applying abs
to both sides. However, it holds for any injective function (one for which f a = f b -> a = b
), which negb
is. Perhaps a better question to ask, then, is given a function which operates on a proposition (for example, negb x = negb y -> x = y
), how can I use that function to modify the current goal?