(************************************************************************)
(*         *      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)         *)
(************************************************************************)
(** Tactics for doing arithmetic proofs. Useful to bootstrap lia. *)
Local Open Scope Z_scope.

(* Specifications: *)
Lemma eq_incl :
forall (x y:Z), x = y -> x <= y /\ y <= x.
Lemma elim_concl_eq :
forall x y, (x < y \/ y < x -> False) -> x = y.
Lemma elim_concl_le :
forall x y, (y < x -> False) -> x <= y.
Lemma elim_concl_lt :
forall x y, (y <= x -> False) -> x < y.
Lemma Zlt_le_add_1 : forall n m : Z, n < m -> n + 1 <= m.
Lemma mul_le : forall e1 e2, 0 <= e1 -> 0 <= e2 -> 0 <= e1*e2.
Fixpoint eval_proof (p : proof) : { e : Z | 0 <= e} :=
match p with
| Hyp e prf => exist _ e prf
| Add p1 p2 => let (e1,p1) := eval_proof p1 in
let (e2,p2) := eval_proof p2 in
exist _ _ (add_le _ _ p1 p2)
| Mul p1 p2  => let (e1,p1) := eval_proof p1 in
let (e2,p2) := eval_proof p2 in
exist _ _ (mul_le _ _ p1 p2)
| Cst c      =>  match Z_le_dec 0 c with
| left prf => exist _ _ prf
|  _       => exist _ _ Z.le_0_1
end
end.