Skip to content

Commit ca9b3eb

Browse files
authored
chore: variants of dite_eq_left_iff (#8357)
This PR adds variants of `dite_eq_left_iff` that will be useful in a future PR.
1 parent a817067 commit ca9b3eb

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

src/Init/Data/Array/OfFn.lean

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ theorem ofFn_succ {f : Fin (n+1) → α} :
2626
ofFn f = (ofFn (fun (i : Fin n) => f i.castSucc)).push (f ⟨n, by omega⟩) := by
2727
ext i h₁ h₂
2828
· simp
29-
· simp [getElem_push]
30-
split <;> rename_i h₃
31-
· rfl
32-
· congr
33-
simp at h₁ h₂
34-
omega
29+
· simp only [getElem_ofFn, getElem_push, size_ofFn, Fin.castSucc_mk, left_eq_dite_iff,
30+
Nat.not_lt]
31+
simp only [size_ofFn] at h₁
32+
intro h₃
33+
simp only [show i = n by omega]
3534

3635
@[simp] theorem _root_.List.toArray_ofFn {f : Fin n → α} : (List.ofFn f).toArray = Array.ofFn f := by
3736
ext <;> simp

src/Init/Data/BitVec/Lemmas.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2261,7 +2261,7 @@ theorem msb_sshiftRight {n : Nat} {x : BitVec w} :
22612261
theorem sshiftRight_add {x : BitVec w} {m n : Nat} :
22622262
x.sshiftRight (m + n) = (x.sshiftRight m).sshiftRight n := by
22632263
ext i
2264-
simp [getElem_sshiftRight, getLsbD_sshiftRight, Nat.add_assoc]
2264+
simp only [getElem_sshiftRight, Nat.add_assoc, msb_sshiftRight, dite_eq_ite]
22652265
by_cases h₂ : n + i < w
22662266
· simp [h₂]
22672267
· simp only [h₂, ↓reduceIte]

src/Init/PropLemmas.lean

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,24 +692,48 @@ attribute [local simp] Decidable.imp_iff_left_iff
692692
@[simp] theorem dite_eq_right_iff {p : Prop} [Decidable p] {x : p → α} {y : α} : (if h : p then x h else y) = y ↔ ∀ h : p, x h = y := by
693693
split <;> simp_all
694694

695+
@[simp] theorem left_eq_dite_iff {p : Prop} [Decidable p] {x : α} {y : ¬ p → α} : x = (if h : p then x else y h) ↔ ∀ h : ¬ p, x = y h := by
696+
split <;> simp_all
697+
698+
@[simp] theorem right_eq_dite_iff {p : Prop} [Decidable p] {x : p → α} {y : α} : y = (if h : p then x h else y) ↔ ∀ h : p, y = x h := by
699+
split <;> simp_all
700+
695701
@[simp] theorem dite_iff_left_iff {p : Prop} [Decidable p] {x : Prop} {y : ¬ p → Prop} : ((if h : p then x else y h) ↔ x) ↔ ∀ h : ¬ p, y h ↔ x := by
696702
split <;> simp_all
697703

698704
@[simp] theorem dite_iff_right_iff {p : Prop} [Decidable p] {x : p → Prop} {y : Prop} : ((if h : p then x h else y) ↔ y) ↔ ∀ h : p, x h ↔ y := by
699705
split <;> simp_all
700706

707+
@[simp] theorem left_iff_dite_iff {p : Prop} [Decidable p] {x : Prop} {y : ¬ p → Prop} : (x ↔ (if h : p then x else y h)) ↔ ∀ h : ¬ p, x ↔ y h := by
708+
split <;> simp_all
709+
710+
@[simp] theorem right_iff_dite_iff {p : Prop} [Decidable p] {x : p → Prop} {y : Prop} : (y ↔ (if h : p then x h else y)) ↔ ∀ h : p, y ↔ x h := by
711+
split <;> simp_all
712+
701713
@[simp] theorem ite_eq_left_iff {p : Prop} [Decidable p] {x y : α} : (if p then x else y) = x ↔ ¬ p → y = x := by
702714
split <;> simp_all
703715

704716
@[simp] theorem ite_eq_right_iff {p : Prop} [Decidable p] {x y : α} : (if p then x else y) = y ↔ p → x = y := by
705717
split <;> simp_all
706718

719+
@[simp] theorem left_eq_ite_iff {p : Prop} [Decidable p] {x y : α} : x = (if p then x else y) ↔ ¬ p → x = y := by
720+
split <;> simp_all
721+
722+
@[simp] theorem right_eq_ite_iff {p : Prop} [Decidable p] {x y : α} : y = (if p then x else y) ↔ p → y = x := by
723+
split <;> simp_all
724+
707725
@[simp] theorem ite_iff_left_iff {p : Prop} [Decidable p] {x y : Prop} : ((if p then x else y) ↔ x) ↔ ¬ p → y = x := by
708726
split <;> simp_all
709727

710728
@[simp] theorem ite_iff_right_iff {p : Prop} [Decidable p] {x y : Prop} : ((if p then x else y) ↔ y) ↔ p → x = y := by
711729
split <;> simp_all
712730

731+
@[simp] theorem left_iff_ite_iff {p : Prop} [Decidable p] {x y : Prop} : (x ↔ (if p then x else y)) ↔ ¬ p → x = y := by
732+
split <;> simp_all
733+
734+
@[simp] theorem right_iff_ite_iff {p : Prop} [Decidable p] {x y : Prop} : (y ↔ (if p then x else y)) ↔ p → y = x := by
735+
split <;> simp_all
736+
713737
@[simp] theorem dite_then_false {p : Prop} [Decidable p] {x : ¬ p → Prop} : (if h : p then False else x h) ↔ ∃ h : ¬ p, x h := by
714738
split <;> simp_all
715739

src/Lean/Meta/Tactic/Grind/Arith/CommRing/Proof.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def PreNullCert.combine (k₁ : Int) (m₁ : Mon) (c₁ : PreNullCert) (k₂ : I
109109
qs := qs.set i q₁
110110
else
111111
have : i < n := h.upper
112-
have : qs₁.size = n ∨ qs₂.size = n := by simp +zetaDelta [Nat.max_def]; split <;> simp [*]
112+
have : qs₁.size = n ∨ qs₂.size = n := by simp +zetaDelta only [Nat.max_def, right_eq_ite_iff]; split <;> simp [*]
113113
have : i < qs₂.size := by omega
114114
let q₂ ← qs₂[i].mulMonM k₂ m₂
115115
qs := qs.set i q₂

src/Std/Data/Internal/List/Associative.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5911,7 +5911,7 @@ theorem minEntry?_insertEntryIfNew [Ord α] [TransOrd α] [BEq α] [LawfulBEqOrd
59115911
have := isSome_minEntry?_of_containsKey hc
59125912
cases h : minEntry? l
59135913
· simp_all
5914-
· simp
5914+
· simp only [Option.some.injEq]
59155915
split
59165916
· have := minKey?_le_of_containsKey hd hc (by simp [minKey?, h]; rfl)
59175917
simp_all [← OrientedCmp.gt_iff_lt]

0 commit comments

Comments
 (0)