Ltac flatten_bool :=
  repeat match goal with
           [ id : (_ && _)%bool = true |- _ ] =>  destruct (andb_prop _ _ id); clear id
         |  [ id : (_ || _)%bool = true |- _ ] =>  destruct (orb_prop _ _ id); clear id
         end.Ltac inv H := inversion H ; try subst ; clear H.

(* Specifications: *)
Lemma eq_le_iff : forall x, 0 = x <-> (0 <= x /\ x <= 0).
Lemma lt_le_iff : forall x, 0 < x <-> 0 <= x - 1.
Lemma le_0_iff : forall x y, x <= y <-> 0 <= y - x.
Lemma le_neg : forall x, ((0 <= x) -> False) <-> 0 < -x.
Lemma eq_cnf : forall x, (0 <= x - 1 -> False) /\ (0 <= -1 - x -> False) <-> x = 0.
Lemma Zsor : SOR 0 1 Z.add Z.mul Z.sub Z.opp (@eq Z) Z.le Z.lt.
Lemma ZSORaddon : SORaddon 0 1 Z.add Z.mul Z.sub Z.opp (@eq Z) Z.le (* ring elements *) 0%Z 1%Z Z.add Z.mul Z.sub Z.opp (* coefficients *) Zeq_bool Z.leb (fun x => x) (fun x => x) (pow_N 1 Z.mul).