Skip to content

Commit

Permalink
feat(logic/basic): dite_eq_ite (#6095)
Browse files Browse the repository at this point in the history
Simplify `dite` to `ite` when possible.


Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
  • Loading branch information
semorrison and semorrison committed Feb 9, 2021
1 parent 8fd8636 commit 7b1945e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/data/real/golden_ratio.lean
Expand Up @@ -154,7 +154,8 @@ begin
intros n,
simp only,
rw [nat.fib_succ_succ, add_comm],
simp [finset.sum_fin_eq_sum_range, finset.sum_range_succ']
simp [finset.sum_fin_eq_sum_range, finset.sum_range_succ'],
refl,
end

/-- The geometric sequence `λ n, φ^n` is a solution of `fib_rec`. -/
Expand Down
4 changes: 2 additions & 2 deletions src/group_theory/perm/sign.lean
Expand Up @@ -268,11 +268,11 @@ lemma sign_bij_aux_surj {n : ℕ} {f : perm (fin n)} : ∀ a ∈ fin_pairs_lt n,
if hxa : f⁻¹ a₂ < f⁻¹ a₁
then ⟨⟨f⁻¹ a₁, f⁻¹ a₂⟩, mem_fin_pairs_lt.2 hxa,
by { dsimp [sign_bij_aux],
rw [apply_inv_self, apply_inv_self, dif_pos (mem_fin_pairs_lt.1 ha)] }⟩
rw [apply_inv_self, apply_inv_self, if_pos (mem_fin_pairs_lt.1 ha)] }⟩
else ⟨⟨f⁻¹ a₂, f⁻¹ a₁⟩, mem_fin_pairs_lt.2 $ (le_of_not_gt hxa).lt_of_ne $ λ h,
by simpa [mem_fin_pairs_lt, (f⁻¹).injective h, lt_irrefl] using ha,
by { dsimp [sign_bij_aux],
rw [apply_inv_self, apply_inv_self, dif_neg (mem_fin_pairs_lt.1 ha).le.not_lt] }⟩
rw [apply_inv_self, apply_inv_self, if_neg (mem_fin_pairs_lt.1 ha).le.not_lt] }⟩

lemma sign_bij_aux_mem {n : ℕ} {f : perm (fin n)} : ∀ a : Σ a : fin n, fin n,
a ∈ fin_pairs_lt n → sign_bij_aux f a ∈ fin_pairs_lt n :=
Expand Down
5 changes: 5 additions & 0 deletions src/logic/basic.lean
Expand Up @@ -1228,6 +1228,11 @@ end nonempty

section ite

/-- A `dite` whose results do not actually depend on the condition may be reduced to an `ite`. -/
@[simp]
lemma dite_eq_ite (P : Prop) [decidable P] {α : Sort*} (x y : α) :
dite P (λ h, x) (λ h, y) = ite P x y := rfl

/-- A function applied to a `dite` is a `dite` of that function applied to each of the branches. -/
lemma apply_dite {α β : Sort*} (f : α → β) (P : Prop) [decidable P] (x : P → α) (y : ¬P → α) :
f (dite P x y) = dite P (λ h, f (x h)) (λ h, f (y h)) :=
Expand Down

0 comments on commit 7b1945e

Please sign in to comment.