End DupfreeLength.
(* * Cardinality *)
Section Cardinality.
Variable X : Type.
Context {eq_X_dec : eq_dec X}.
Implicit Types A B : list X.
Definition card (A : list X) : nat := |undup A|.

(* Specifications: *)
Lemma card_le A B :
A <<= B -> card A <= card B.
Lemma card_eq A B :
A === B -> card A = card B.
Lemma card_equi A B :
A <<= B -> card A = card B -> A === B.
Lemma card_lt A B x :
A <<= B -> x el B -> ~ x el A -> card A < card B.
Lemma card_or A B :
A <<= B -> A === B \/ card A < card B.
Lemma card_ex A B :
card A < card B -> exists x, x el B /\ ~ x el A.
Lemma card_cons x A :
card (x::A) = if decision (x el A) then card A else 1 + card A.
Lemma card_cons_rem x A :
card (x::A) = 1 + card (rem A x).
Lemma card_0 A :
card A = 0 -> A = nil.