booleans #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This file proves various trivial lemmas about booleans and their relation to decidable propositions.
Notations #
This file introduces the notation !b
for bnot b
, the boolean "not".
Tags #
bool, boolean, De Morgan
@[simp]
@[simp]
@[simp]
@[simp]
theorem
bool.to_bool_and
(p q : Prop)
[decidable p]
[decidable q] :
decidable.to_bool (p ∧ q) = decidable.to_bool p && decidable.to_bool q
@[simp]
theorem
bool.to_bool_or
(p q : Prop)
[decidable p]
[decidable q] :
decidable.to_bool (p ∨ q) = decidable.to_bool p || decidable.to_bool q
@[simp]
theorem
bool.to_bool_eq
{p q : Prop}
[decidable p]
[decidable q] :
decidable.to_bool p = decidable.to_bool q ↔ (p ↔ q)
@[protected, instance]
If p b
is decidable for all b : bool
, then ∀ b, p b
is decidable
Equations
- bool.decidable_forall_bool = decidable_of_decidable_of_iff and.decidable bool.decidable_forall_bool._proof_1
@[protected, instance]
If p b
is decidable for all b : bool
, then ∃ b, p b
is decidable
Equations
- bool.decidable_exists_bool = decidable_of_decidable_of_iff or.decidable bool.decidable_exists_bool._proof_1
@[simp]
theorem
bool.cond_to_bool
{α : Type u_1}
(p : Prop)
[decidable p]
(t e : α) :
cond (decidable.to_bool p) t e = ite p t e
De Morgan's laws for booleans #
@[protected, instance]
Equations
- bool.linear_order = {le := λ (a b : bool), a = bool.ff ∨ b = bool.tt, lt := partial_order.lt._default (λ (a b : bool), a = bool.ff ∨ b = bool.tt), le_refl := bool.linear_order._proof_1, le_trans := bool.linear_order._proof_2, lt_iff_le_not_le := bool.linear_order._proof_3, le_antisymm := bool.linear_order._proof_4, le_total := bool.linear_order._proof_5, decidable_le := infer_instance (λ (a b : bool), or.decidable), decidable_eq := infer_instance (λ (a b : bool), bool.decidable_eq a b), decidable_lt := decidable_lt_of_decidable_le infer_instance, max := bor, max_def := bool.linear_order._proof_10, min := band, min_def := bool.linear_order._proof_11}
convert a ℕ
to a bool
, 0 -> false
, everything else -> true
Equations
- bool.of_nat n = decidable.to_bool (n ≠ 0)
@[simp]
theorem
bool.injective_iff
{α : Sort u_1}
{f : bool → α} :
function.injective f ↔ f bool.ff ≠ f bool.tt