intuition.
unfold eqbBvector.
apply eqb_vector_refl.
Qed.
Instance Bvector_EqDec n : EqDec (Bvector n).
refine {| eqb := (@eqbBvector n) |}.
intuition.
eapply eqbBvector_sound; auto.
intuition.
subst.
eapply eqbBvector_complete; eauto.
Defined.
Instance nat_EqDec : EqDec nat.
refine {| eqb := (fun x y => (leb x y) && (leb y x)) |}.
intuition.
apply andb_true_iff in H.
intuition.
eapply le_antisym;
eapply leb_iff; eauto.
apply andb_true_iff.
intuition;
eapply leb_iff; subst; eapply le_refl.
Qed.
Definition eqbPair (A B : Set)(dA : EqDec A)(dB : EqDec B)(p1 p2 : (A*B)) :=
(eqb (fst p1) (fst p2)) && (eqb (snd p1) (snd p2)).
Instance pair_EqDec (A B : Set) (dA : EqDec A) (dB : EqDec B) : EqDec (prod A B).
refine {| eqb := (@eqbPair A B dA dB) |}.
intuition; unfold eqbPair in *; simpl in *.
apply andb_true_iff in H.
intuition.
f_equal;
eapply eqb_leibniz; trivial.
inversion H; subst; clear H.
apply andb_true_iff; intuition;
eapply eqb_leibniz; trivial.
Defined.
Definition eqbSum(A B : Set)(dA : EqDec A)(dB : EqDec B)(s1 s2 : (A + B)) :=
match s1 with
| inl a1 =>
match s2 with
| inl a2 => eqb a1 a2
| inr b2 => false
end
| inr b1 =>
match s2 with
| inl a2 => false
| inr b2 => eqb b1 b2
end
end.
Instance sum_EqDec (A B : Set) (dA : EqDec A) (dB : EqDec B) :
EqDec (sum A B).
refine {| eqb := (@eqbSum A B dA dB) |}.
intuition; unfold eqbSum in *; try
match goal with
| [H : eqb _ _ = true |-_] => rewrite eqb_leibniz in H
| [H : inl _ = inl _ |-_] => inversion H
| [H : inr _ = inr _ |-_] => inversion H
end; subst; try rewrite eqb_refl; trivial; try discriminate.
Defined.
Definition eqbOption (A : Set)(dA : EqDec A)(o1 o2 : option A) :=
match o1 with
| None =>
match o2 with
| None => true
| Some _ => false
end
| Some a1 =>
match o2 with
| None => false
| Some a2 => (eqb a1 a2)
end
end.
Instance option_EqDec (A : Set) (dA : EqDec A) : EqDec (option A).
refine {| eqb := (@eqbOption A dA ) |}.
intuition; unfold eqbOption in *; simpl in *.
destruct x.
destruct y.
f_equal.
eapply eqb_leibniz; trivial.
discriminate.
destruct y.
discriminate.
trivial.
subst.
destruct y.
eapply eqb_leibniz; trivial.
trivial.
Qed.
Local Open Scope list_scope.
Fixpoint eqbList(A : Set)(eqd : EqDec A)(ls1 ls2 : list A) :=
match ls1 with
| nil =>
match ls2 with
| nil => true
| _ :: _ => false
end
| a1 :: ls1' =>
match ls2 with
| nil => false
| a2 :: ls2' =>
(eqb a1 a2) && (eqbList _ ls1' ls2')
end
end.

Lemma eqbList_correct1 : forall (A : Set)(eqd : EqDec A) ls1 ls2,
eqbList eqd ls1 ls2 = true ->
ls1 = ls2.