(* 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.(* 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.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.

(* Specifications: *)
Lemma repetition_dec: forall (f:nat -> X) x n, (exists i, i<n /\ f(i) = x) \/ (forall i, i<n -> f i <> x).
Lemma finite_cardinality: forall (P:X->Prop) (EM: forall x, P x \/ ~ P x), finite P -> exists n, cardinality P n.
Lemma filtered_konigsafe: forall (x : X), (forall P : Prop, P \/ ~ P) -> (forall x0 : X, Filter x0 -> finite (R x0)) -> Filter x -> (forall n : nat, safeN X R n x) -> konig.safe X R x.
Lemma schedule_dec: forall (U U':SCH), (U=U') \/ (U<>U').