Zdivides

# Library Zdivides

`Require Export Omega.
Require Export Paux.
Definition oZ1 (x : Option positive) :=
match x with
| None => 0%Z
| Some z => Zpos z
end.
Definition Zquotient (n m : Z) :=
match n, m with
| Z0, _ => 0%Z
| _, Z0 => 0%Z
| Zpos x, Zpos y => match Pdiv x y with
| (x, _) => oZ1 x
end
| Zneg x, Zneg y => match Pdiv x y with
| (x, _) => oZ1 x
end
| Zpos x, Zneg y => match Pdiv x y with
| (x, _) => (- oZ1 x)%Z
end
| Zneg x, Zpos y => match Pdiv x y with
| (x, _) => (- oZ1 x)%Z
end
end.
Theorem inj_oZ1 : forall z, oZ1 z = Z_of_nat (oZ z).
Theorem Zero_le_oZ : forall z, 0 <= oZ z.
Hint Resolve Zero_le_oZ: arith.
Theorem ZquotientProp :
forall m n : Z,
n <> 0%Z ->
ex
(fun r : Z =>
m = (Zquotient m n * n + r)%Z /\
(Zabs (Zquotient m n * n) <= Zabs m)%Z /\ (Zabs r < Zabs n)%Z).
Theorem ZquotientPos :
forall z1 z2 : Z, (0 <= z1)%Z -> (0 <= z2)%Z -> (0 <= Zquotient z1 z2)%Z.
Definition Zdivides (n m : Z) := exists q : Z, n = (m * q)%Z.
Theorem ZdividesZquotient :
forall n m : Z, m <> 0%Z -> Zdivides n m -> n = (Zquotient n m * m)%Z.
Theorem ZdividesZquotientInv :
forall n m : Z, n = (Zquotient n m * m)%Z -> Zdivides n m.
Theorem ZdividesMult :
forall n m p : Z, Zdivides n m -> Zdivides (p * n) (p * m).
Theorem Zeq_mult_simpl :
forall a b c : Z, c <> 0%Z -> (a * c)%Z = (b * c)%Z -> a = b.
Theorem ZdividesDiv :
forall n m p : Z, p <> 0%Z -> Zdivides (p * n) (p * m) -> Zdivides n m.
Definition ZdividesP : forall n m : Z, {Zdivides n m} + {~ Zdivides n m}.
Theorem Zquotient1 : forall m : Z, Zquotient m 1 = m.
Theorem Zdivides1 : forall m : Z, Zdivides m 1.
Theorem Zabs_eq_case :
forall z1 z2 : Z, Zabs z1 = Zabs z2 -> z1 = z2 \/ z1 = (- z2)%Z.
Theorem Zabs_tri : forall z1 z2 : Z, (Zabs (z1 + z2) <= Zabs z1 + Zabs z2)%Z.
Hint Resolve Zabs_tri: zarith.
Theorem ZquotientUnique :
forall m n q r : Z,
n <> 0%Z ->
m = (q * n + r)%Z ->
(Zabs (q * n) <= Zabs m)%Z -> (Zabs r < Zabs n)%Z -> q = Zquotient m n.
Theorem ZquotientZopp :
forall m n : Z, Zquotient (- m) n = (- Zquotient m n)%Z.
Theorem ZquotientMonotone :
forall n m q : Z,
(Zabs n <= Zabs m)%Z -> (Zabs (Zquotient n q) <= Zabs (Zquotient m q))%Z.
Theorem NotDividesDigit :
forall r v : Z,
(1 < r)%Z -> v <> 0%Z -> ~ Zdivides v (Zpower_nat r (digit r v)).
Theorem ZDividesLe :
forall n m : Z, n <> 0%Z -> Zdivides n m -> (Zabs m <= Zabs n)%Z.
Theorem Zquotient_mult_comp :
forall m n p : Z, p <> 0%Z -> Zquotient (m * p) (n * p) = Zquotient m n.
Theorem ZDivides_add :
forall n m p : Z, Zdivides n p -> Zdivides m p -> Zdivides (n + m) p.
Theorem NDivides_minus :
forall n m p : Z, Zdivides n p -> Zdivides m p -> Zdivides (n - m) p.
Theorem ZDivides_mult :
forall n m p q : Z, Zdivides n p -> Zdivides m q -> Zdivides (n * m) (p * q).
Theorem ZdividesTrans :
forall n m p : Z, Zdivides n m -> Zdivides m p -> Zdivides n p.
Theorem ZdividesLessPow :
forall (n : Z) (m p : nat),
m <= p -> Zdivides (Zpower_nat n p) (Zpower_nat n m).
`