# Examples of Decidable Type structures.

A particular case of DecidableType where the equality is the usual one of Coq.

Module Type UsualDecidableType.
Parameter Inline t : Type.
Definition eq := @eq t.
Definition eq_refl := @refl_equal t.
Definition eq_sym := @sym_eq t.
Definition eq_trans := @trans_eq t.
Parameter eq_dec : forall x y, { eq x y }+{~eq x y }.
End UsualDecidableType.

a UsualDecidableType is in particular an DecidableType.

Module UDT_to_DT (U:UsualDecidableType) <: DecidableType := U.

an shortcut for easily building a UsualDecidableType

Module Type MiniDecidableType.
Parameter Inline t : Type.
Parameter eq_dec : forall x y:t, { x=y }+{ x<>y }.
End MiniDecidableType.

Module Make_UDT (M:MiniDecidableType) <: UsualDecidableType.
Definition t:=M.t.
Definition eq := @eq t.
Definition eq_refl := @refl_equal t.
Definition eq_sym := @sym_eq t.
Definition eq_trans := @trans_eq t.
Definition eq_dec := M.eq_dec.
End Make_UDT.

An OrderedType can now directly be seen as a DecidableType

Module OT_as_DT (O:OrderedType) <: DecidableType := O.

(Usual) Decidable Type for nat, positive, N, Z
From two decidable types, we can build a new DecidableType over their cartesian product.

Module PairDecidableType(D1 D2:DecidableType) <: DecidableType.

Definition t := prod D1.t D2.t.

Definition eq x y := D1.eq (fst x) (fst y) /\ D2.eq (snd x) (snd y).

Lemma eq_refl : forall x : t, eq x x.

Lemma eq_sym : forall x y : t, eq x y -> eq y x.

Lemma eq_trans : forall x y z : t, eq x y -> eq y z -> eq x z.

Definition eq_dec : forall x y, { eq x y }+{ ~eq x y }.

End PairDecidableType.

Similarly for pairs of UsualDecidableType

Module PairUsualDecidableType(D1 D2:UsualDecidableType) <: UsualDecidableType.
Definition t := prod D1.t D2.t.
Definition eq := @eq t.
Definition eq_refl := @refl_equal t.
Definition eq_sym := @sym_eq t.
Definition eq_trans := @trans_eq t.
Definition eq_dec : forall x y, { eq x y }+{ ~eq x y }.

End PairUsualDecidableType.