(** Divides with bounded ex quantifier. *)

Definition bDivides (d n : nat) :=
  n = 0 \/ (exists q : nat, q < S n /\ n = d * q).

(* Specifications: *)
Lemma divbdiv : forall n d : nat, Divides d n <-> bDivides d n.
Lemma bdivdec : forall n d : nat, bDivides d n \/ ~ bDivides d n.
Lemma divdec : forall n d : nat, Divides d n \/ ~ Divides d n.
Theorem sqrdivbound : forall n d : nat, Divides d n -> exists x : nat, Divides x n /\ x * x <= n /\ (x = d \/ d * x = n).
Theorem div_rem : forall d n : nat, d > 0 -> exists q : nat, (exists r : nat, 0 <= r /\ r < d /\ n = q * d + r).
Lemma div_rem0 : forall n d q r : nat, n = q * d + r -> r < d -> Divides d n -> r = 0.
Theorem notdiv_rem : forall d n : nat, 0 < d -> ~ Divides d n -> exists q : nat, (exists r : nat, 0 < r /\ r < d /\ n = q * d + r).
Lemma div_plus_compat : forall a b c : nat, Divides a b -> Divides a c -> Divides a (b + c).
Lemma div_minus_compat : forall a b d : nat, Divides d a -> Divides d b -> Divides d (a - b).
Lemma div_mult_compat_l : forall a b c : nat, Divides a b -> Divides a (b * c).
Lemma div_absexp_compat : forall (b : Z) (d : nat), Divides d (Zabs_nat b) -> forall n : nat, Divides d (Zabs_nat (Exp b (S n))).
Lemma div_plus_r : forall a b d : nat, Divides d a -> Divides d (a + b) -> Divides d b.