I want to write a function that calculate count of true values of p 0 .. p t in a nat->prop function.
Section count_sc.
Variable p:nat->Prop.
Hypothesis p_dec:forall x:nat , {p x} + { ~ p x }.
Fixpoint count (x : nat) :=
match x with
| 0 => if p_dec(0) then 1 else 0
| S y => if p_dec(x) then 1+count y else count y
end.
End count_sc.
Definition fret (x:nat) := False.
Check count.
Axiom fret_dec : forall x : nat , { fret x } + { ~ fret x }.
Theorem hello_decide : forall x : nat , count fret fret_dec x = 0.
Proof.
intros.
induction x.
unfold count.
replace (fret_dec 0) with false.
Qed.
Before the replace tactic i should proof some goal like this:
(if fret_dec 0 then 1 else 0) = 0
Coq dose not automaticly compute the value of the if statement. and if i try to replace the fret_dec with it's value, i will get this error:
Error: Terms do not have convertible types.
How i can write count function that i can unfold and use it in theorems?