I am trying to learn Coq mathematical proof language, but I ran into some problems trying to prove something that I led to the following stupid statement:
Lemma foo: forall b: bool, b = true -> (if b then 0 else 1) = 0.
Here is my attempt:
proof. let b: bool. let H: (b = true).
At this point, the proof:
b : bool H : b = true ============================ thesis := (if b then 0 else 1) = 0
Now I want to rewrite the condition if b to true in order to be able to prove the thesis. However, the "small step"
have ((if b then 0 else 1) = (if true then 0 else 1)) by H.
and the "bigger step"
have ((if b then 0 else 1) = 0) by H.
fail with Warning: Insufficient justification. I don’t think that something is wrong with rewriting in the state, since the normal tactics of rewrite -> H will do the same.
I can also make this work without problems by wrapping an if in a function:
Definition ite (cond: bool) (ab: nat) := if cond then a else b. Lemma bar: forall b: bool, b = true -> (ite b 0 1) = 0. proof. let b: bool. let H: (b = true). have (ite b 0 1 = ite true 0 1) by H. thus ~= 0. end proof.
This is not very nice, of course. Am I doing something wrong? Is there a way to save my original evidence? Is it just a flaw in the implementation of the language of mathematical evidence?
I note that in section 11.3.3 of the manual there is a possible related example ( https://coq.inria.fr/doc/Reference-Manual013.html ):
a := false : bool b := true : bool H : False ============================ thesis := if b then True else False Coq < reconsider thesis as True.
But I do not know how to get the b := true part in context.