(************************************************************************)
(*         *   The Coq Proof Assistant / The Coq Development Team       *)
(*  v      *   INRIA, CNRS and contributors - Copyright 1999-2018       *)
(* <O___,, *       (see CREDITS file for the list of authors)           *)
(*   \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)         *)
(************************************************************************)
(** The type [bool] is defined in the prelude as [Inductive bool : Set := true : bool | false : bool] *)
(** Most of the lemmas in this file are trivial after breaking all booleans *)
Ltac destr_bool :=
intros; destruct_all bool; simpl in *; trivial; try discriminate.
(** Interpretation of booleans as propositions *)
Definition Is_true (b:bool) :=
match b with
| true => True
| false => False
end.
(*******************)
(** * Decidability *)
(*******************)
Hint Resolve diff_true_false : bool.
Hint Resolve diff_false_true : bool.
Hint Extern 1 (false <> true) => exact diff_false_true : core.
(**********************)
(** * Order on booleans *)
(**********************)
Definition leb (b1 b2:bool) :=
match b1 with
| true => b2 = true
| false => True
end.
Hint Unfold leb: bool.
(* Infix "<=" := leb : bool_scope. *)
(*************)
(** * Equality *)
(*************)
Definition eqb (b1 b2:bool) : bool :=
match b1, b2 with
| true, true => true
| true, false => false
| false, true => false
| false, false => true
end.
(************************)
(** * A synonym of [if] on [bool] *)
(************************)
Definition ifb (b1 b2 b3:bool) : bool :=
match b1 with
| true => b2
| false => b3
end.
Open Scope bool_scope.
(****************************)
(** * De Morgan laws          *)
(****************************)
(********************************)
(** * Properties of [negb]    *)
(********************************)
Notation negb_elim := negb_involutive (only parsing).
Notation negb_intro := negb_involutive_reverse (only parsing).
(********************************)
(** * Properties of [orb]     *)
(********************************)
Hint Resolve orb_true_intro: bool.
Hint Resolve orb_false_intro: bool.
(** [true] is a zero for [orb] *)
Hint Resolve orb_true_r: bool.
Notation orb_b_true := orb_true_r (only parsing).
Notation orb_true_b := orb_true_l (only parsing).
(** [false] is neutral for [orb] *)
Hint Resolve orb_false_r: bool.
Hint Resolve orb_false_l: bool.
Notation orb_b_false := orb_false_r (only parsing).
Notation orb_false_b := orb_false_l (only parsing).
(** Complementation *)
Hint Resolve orb_negb_r: bool.
Notation orb_neg_b := orb_negb_r (only parsing).
(** Commutativity *)
(** Associativity *)
Hint Resolve orb_comm orb_assoc: bool.
(*******************************)
(** * Properties of [andb]     *)
(*******************************)
(** [false] is a zero for [andb] *)
Notation andb_b_false := andb_false_r (only parsing).
Notation andb_false_b := andb_false_l (only parsing).
(** [true] is neutral for [andb] *)
Notation andb_b_true := andb_true_r (only parsing).
Notation andb_true_b := andb_true_l (only parsing).
Hint Resolve andb_negb_r: bool.
Notation andb_neg_b := andb_negb_r (only parsing).
(** Commutativity *)
(** Associativity *)
Hint Resolve andb_comm andb_assoc: bool.
(*******************************************)
(** * Properties mixing [andb] and [orb] *)
(*******************************************)
(** Distributivity *)
(* Compatibility *)
Notation demorgan1 := andb_orb_distrib_r (only parsing).
Notation demorgan2 := andb_orb_distrib_l (only parsing).
Notation demorgan3 := orb_andb_distrib_r (only parsing).
Notation demorgan4 := orb_andb_distrib_l (only parsing).
(** Absorption *)
(* begin hide *)
(* Compatibility *)
Notation absoption_andb := absorption_andb (only parsing).
Notation absoption_orb := absorption_orb (only parsing).
(* end hide *)
(*********************************)
(** * Properties of [xorb]       *)
(*********************************)
(** [false] is neutral for [xorb] *)
Notation xorb_false := xorb_false_r (only parsing).
Notation false_xorb := xorb_false_l (only parsing).
(** [true] is "complementing" for [xorb] *)
Notation xorb_true := xorb_true_r (only parsing).
Notation true_xorb := xorb_true_l (only parsing).
(** Nilpotency (alternatively: identity is a inverse for [xorb]) *)
(** Commutativity *)
(** Associativity *)
Notation xorb_assoc := xorb_assoc_reverse (only parsing). (* Compatibility *)

Lemma xorb_eq : forall b b':bool, xorb b b' = false -> b = b'.