(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)
Local Open Scope Z_scope.
(** Factorization lemmas *)

(* Specifications: *)
Theorem Zred_factor0 n : n = n * 1.
Theorem Zred_factor1 n : n + n = n * 2.
Theorem Zred_factor2 n m : n + n * m = n * (1 + m).
Theorem Zred_factor3 n m : n * m + n = n * (1 + m).
Theorem Zred_factor4 n m p : n * m + n * p = n * (m + p).
Theorem Zred_factor5 n m : n * 0 + m = m.
Theorem Zred_factor6 n : n = n + 0.
(** Other specific variants of theorems dedicated for the Omega tactic *)
Lemma new_var : forall x : Z, exists y : Z, x = y.
Lemma OMEGA1 x y : x = y -> 0 <= x -> 0 <= y.
Lemma OMEGA2 x y : 0 <= x -> 0 <= y -> 0 <= x + y.
Lemma OMEGA3 x y k : k > 0 -> x = y * k -> x = 0 -> y = 0.
Lemma OMEGA4 x y z : x > 0 -> y > x -> z * y + x <> 0.
Lemma OMEGA5 x y z : x = 0 -> y = 0 -> x + y * z = 0.
Lemma OMEGA6 x y z : 0 <= x -> y = 0 -> 0 <= x + y * z.
Lemma OMEGA7 x y z t :
z > 0 -> t > 0 -> 0 <= x -> 0 <= y -> 0 <= x * z + y * t.
Lemma OMEGA8 x y : 0 <= x -> 0 <= y -> x = - y -> x = 0.
Lemma OMEGA9 x y z t : y = 0 -> x = z -> y + (- x + z) * t = 0.
Lemma OMEGA10 v c1 c2 l1 l2 k1 k2 :
(v * c1 + l1) * k1 + (v * c2 + l2) * k2 =
v * (c1 * k1 + c2 * k2) + (l1 * k1 + l2 * k2).
Lemma OMEGA11 v1 c1 l1 l2 k1 :
(v1 * c1 + l1) * k1 + l2 = v1 * (c1 * k1) + (l1 * k1 + l2).
Lemma OMEGA12 v2 c2 l1 l2 k2 :
l1 + (v2 * c2 + l2) * k2 = v2 * (c2 * k2) + (l1 + l2 * k2).
Lemma OMEGA13 (v l1 l2 : Z) (x : positive) :
v * Zpos x + l1 + (v * Zneg x + l2) = l1 + l2.
Lemma OMEGA14 (v l1 l2 : Z) (x : positive) :
v * Zneg x + l1 + (v * Zpos x + l2) = l1 + l2.
Lemma OMEGA15 v c1 c2 l1 l2 k2 :
v * c1 + l1 + (v * c2 + l2) * k2 = v * (c1 + c2 * k2) + (l1 + l2 * k2).
Lemma OMEGA16 v c l k : (v * c + l) * k = v * (c * k) + l * k.
Lemma OMEGA17 x y z : Zne x 0 -> y = 0 -> Zne (x + y * z) 0.
Lemma OMEGA18 x y k : x = y * k -> Zne x 0 -> Zne y 0.
Lemma OMEGA19 x : Zne x 0 -> 0 <= x + -1 \/ 0 <= x * -1 + -1.
Lemma OMEGA20 x y z : Zne x 0 -> y = 0 -> Zne (x + y * z) 0.
Definition fast_Zplus_comm (x y : Z) (P : Z -> Prop)
(H : P (y + x)) := eq_ind_r P H (Z.add_comm x y).