(************************************************************************)
(*         *      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.
(* Instances of [ZifyClasses] for dealing with boolean operators. *)
#[global]
Instance Inj_bool_bool : InjTyp bool bool :=
{ inj b := b ; pred b := b = true \/ b = false ;
cstr b := ltac:(destruct b; tauto) }.
Add Zify InjTyp Inj_bool_bool.
(** Boolean operators *)
#[global]
Instance Op_andb : BinOp andb :=
{ TBOp := andb ; TBOpInj _ _ := eq_refl}.
Add Zify BinOp Op_andb.
#[global]
Instance Op_orb : BinOp orb :=
{ TBOp := orb ; TBOpInj _ _ := eq_refl}.
Add Zify BinOp Op_orb.
#[global]
Instance Op_implb : BinOp implb :=
{ TBOp := implb; TBOpInj _ _ := eq_refl }.
Add Zify BinOp Op_implb.

(* Specifications: *)
Lemma xorb_eq b1 b2 : xorb b1 b2 = andb (orb b1 b2) (negb (eqb b1 b2)).
#[global]
Instance Op_xorb : BinOp xorb :=
{ TBOp x y := andb (orb x y) (negb (eqb x y)); TBOpInj := xorb_eq }.