(* nat misc *)

Definition ltb (x y: nat): bool := negb (leb y x).Definition geb (x y: nat): bool := leb y x.Ltac subst_tac x y z := (* todo: rename *)
  match z with
  | x => y
  | ?l + ?r =>
      let l' := subst_tac x y l in
      let r' := subst_tac x y r in
        constr: (l' + r')
  | ?l * ?r =>
      let l' := subst_tac x y l in
      let r' := subst_tac x y r in
        constr: (l' * r')
  | _ => z
  end.Ltac deep_le_trans h :=
  match type of h with
  | ?n <= ?u =>
    match goal with
    | |- ?l <= _ =>
      let q := subst_tac n u l
      in apply le_trans with q
    end
  end.Instance Transitive_le: Transitive le := le_trans.

(* Specifications: *)
Lemma minus_plus_same (y x: nat): x <= x - y + y.
Lemma ltb_complete m n: ltb m n = true -> m < n.
Lemma ltb_complete_conv m n: ltb m n = false -> n <= m.
Lemma lt_0_mult x y: 0 < x -> 0 < y -> 0 < x * y.
Lemma mult_ne_0 a b: (a <> 0 -> b <> 0 -> mult a b <> 0)%nat.
Lemma weak_lt_S_n n m: S n < m -> n < m.
Lemma le_exists_plus (x y: nat) (p: x <= y): exists d, y = x + d.
Lemma lt_exists_plus (x y: nat) (p: x < y): exists d, y = S (x + d).
Lemma n_lt_n_plus_Sm n m: n < n + S m.
Lemma ne_le_impl_lt x y: x <> y -> x <= y -> x < y.
Lemma beq_nat_false x y: x <> y -> beq_nat x y = false.
Lemma minus_lt_compat_l x y z: (y <= x -> z < y -> x - y < x - z)%nat.
Lemma minus_eq_inv_r d x y: (x <= d -> y <= d -> (d - x = d - y) -> x = y)%nat.
Lemma le_ne_lt x y: x <= y -> x <> y -> x < y.
Lemma ne_nlt_lt x y: x <> y -> ~ x < y -> y < x.
Lemma lt_not_eq x y: (x < y -> x <> y)%nat.
Lemma lt_not_eq_sym x y: (y < x -> x <> y)%nat.