Module docstring
{"# by_cases tactic and if-then-else support ","## if-then-else "}
{"# by_cases tactic and if-then-else support ","## if-then-else "}
tacticBy_cases_:_
definition
: Lean.ParserDescr✝
if_true
theorem
{_ : Decidable True} (t e : α) : ite True t e = t
if_false
theorem
{_ : Decidable False} (t e : α) : ite False t e = e
ite_id
theorem
[Decidable c] {α} (t : α) : (if c then t else t) = t
theorem ite_id [Decidable c] {α} (t : α) : (if c then t else t) = t := by split <;> rfl
apply_dite
theorem
(f : α → β) (P : Prop) [Decidable P] (x : P → α) (y : ¬P → α) :
f (dite P x y) = dite P (fun h => f (x h)) (fun h => f (y h))
/-- A function applied to a `dite` is a `dite` of that function applied to each of the branches. -/
theorem apply_dite (f : α → β) (P : Prop) [Decidable P] (x : P → α) (y : ¬P → α) :
f (dite P x y) = dite P (fun h => f (x h)) (fun h => f (y h)) := by
by_cases h : P <;> simp [h]
apply_ite
theorem
(f : α → β) (P : Prop) [Decidable P] (x y : α) : f (ite P x y) = ite P (f x) (f y)
/-- A function applied to a `ite` is a `ite` of that function applied to each of the branches. -/
theorem apply_ite (f : α → β) (P : Prop) [Decidable P] (x y : α) :
f (ite P x y) = ite P (f x) (f y) :=
apply_dite f P (fun _ => x) (fun _ => y)
dite_eq_ite
theorem
[Decidable P] : (dite P (fun _ => a) (fun _ => b)) = ite P a b
/-- A `dite` whose results do not actually depend on the condition may be reduced to an `ite`. -/
@[simp] theorem dite_eq_ite [Decidable P] :
(dite P (fun _ => a) (fun _ => b)) = ite P a b := rfl
ite_some_none_eq_none
theorem
[Decidable P] : (if P then some x else none) = none ↔ ¬P
@[deprecated "Use `ite_eq_right_iff`" (since := "2024-09-18")]
theorem ite_some_none_eq_none [Decidable P] :
(if P then some x else none) = none ↔ ¬ P := by
simp only [ite_eq_right_iff, reduceCtorEq]
rfl
ite_some_none_eq_some
theorem
[Decidable P] : (if P then some x else none) = some y ↔ P ∧ x = y
@[deprecated "Use `Option.ite_none_right_eq_some`" (since := "2024-09-18")]
theorem ite_some_none_eq_some [Decidable P] :
(if P then some x else none) = some y ↔ P ∧ x = y := by
split <;> simp_all
dite_some_none_eq_none
theorem
[Decidable P] {x : P → α} : (if h : P then some (x h) else none) = none ↔ ¬P
@[deprecated "Use `dite_eq_right_iff" (since := "2024-09-18")]
theorem dite_some_none_eq_none [Decidable P] {x : P → α} :
(if h : P then some (x h) else none) = none ↔ ¬P := by
simp
dite_some_none_eq_some
theorem
[Decidable P] {x : P → α} {y : α} : (if h : P then some (x h) else none) = some y ↔ ∃ h : P, x h = y
@[deprecated "Use `Option.dite_none_right_eq_some`" (since := "2024-09-18")]
theorem dite_some_none_eq_some [Decidable P] {x : P → α} {y : α} :
(if h : P then some (x h) else none) = some y ↔ ∃ h : P, x h = y := by
by_cases h : P <;> simp [h]