(* the number of different elements in X is finite *)
Inductive cardinality {X} (P:X->Prop): nat -> Prop:=
|Cardinality n (f:nat-> X): (forall i j, i<n -> j<n -> i<>j -> f(i)<>f(j)) ->
(forall i, i<n -> P (f i)) ->
(forall x, P x -> exists i, i < n /\ f i = x) ->
cardinality P n.
Inductive cardinality' {X} (P:X->Prop): nat -> Prop:=
|Cardinality' n (f:nat-> X): (forall i j, i<n -> j<n -> i<>j  -> f(i)<>f(j)) ->
(forall i, i<n -> P (f i)) ->
cardinality' P n.

Lemma finite_cardinality:
forall (P:X->Prop) (EM: forall x, P x \/ ~ P x), finite P -> exists n, cardinality P n.