Library IntBool


Require Import ZArith.
Require Export Bool.

Definition int := Z.

Open Scope Z_scope.

Theorem int_eq_dec : forall a b : int, {a = b} + {a <> b}.

Fixpoint blt_pos (p q : positive) {struct p} : bool :=
  match (Pcompare p q Eq) with
    | Lt => true
    | _ => false
  end.

Fixpoint blt_int (n m : int) {struct n} : bool :=
  match n, m with
    | Z0, Zpos p => true
    | Zneg p, Z0 => true
    | Zneg p, Zpos q => true
    | Zneg p, Zneg q => blt_pos q p
    | Zpos p, Zpos q => blt_pos p q
    | _, _ => false
  end.

Lemma blt_pos_irrefl :
  forall p : positive, blt_pos p p = false.

Lemma blt_irrefl :
  forall a : int, blt_int a a = false.

Lemma blt_irrefl_Prop :
  forall a : int, ~ (blt_int a a = true).

Fixpoint beq_pos (p : positive) {struct p} : bool :=
  match p, with
    | x~0, ~0 => andb true (beq_pos x )
    | p~1, ~1 => andb true (beq_pos p )
    | 1, 1 => true
    | _, _ => false
  end %positive.

Fixpoint beq_int (z : int) {struct z} : bool :=
  match z, with
    | Z0, Z0 => true
    | Zpos p, Zpos => beq_pos p
    | Zneg p, Zneg => beq_pos p
    | _, _ => false
  end.

Lemma beq_int_true_eq : forall z : int,
  beq_int z = true -> z = .

Lemma beq_int_false_neq : forall z : int,
  beq_int z = false -> z <> .

Lemma eq_beq_int_true : forall z : int,
  z = -> beq_int z = true.

Lemma neq_beq_int_false : forall z : int,
  z <> -> beq_int z = false.

Lemma beq_int_dec : forall a b,
  {beq_int a b = true} + {beq_int a b = false}.

Ltac beq_case_tac x y :=
  let Hb := fresh "Hb" in
    (destruct (beq_int_dec x y) as [Hb | Hb]; trivial).

Tactic Notation "bint" "case" constr(i) constr () := beq_case_tac i .