I'm reading Software Foundations book and in Imp.v file, there is this definition of a theorem eq_id_dec as follows:
Theorem eq_id_dec : forall id1 id2 : id, {id1 = id2} + {id1 <> id2}.
Proof.
intros id1 id2.
destruct id1 as [n1]. destruct id2 as [n2].
destruct (eq_nat_dec n1 n2) as [Heq | Hneq].
Case "n1 = n2".
left. rewrite Heq. reflexivity.
Case "n1 <> n2".
right. intros contra. inversion contra. apply Hneq. apply H0.
Defined.
Does this theorem mean that for any id1 and id2 of type id, both id1=id2 and id1!=id2 cannot happen? I'm not sure.
No, it does not preclude the case that both the equality and the inequality are true at the same time (though in practice it is the case here).
The type
sumbool A B, of notation{A} + {B}, characterizes a decision procedure that will prove eitherAorB.So this
eq_id_decis a term that will take twoids as input, and either return a proof that they are equal, or a proof that they are distinct.More about sumbool here: https://coq.inria.fr/distrib/current/stdlib/Coq.Bool.Sumbool.html