diff --git a/src/data/fin/basic.lean b/src/data/fin/basic.lean index 49f05ace3cc03..aaba0b515ee0f 100644 --- a/src/data/fin/basic.lean +++ b/src/data/fin/basic.lean @@ -1014,7 +1014,7 @@ lemma forall_fin_two {p : fin 2 → Prop} : (∀ i, p i) ↔ p 0 ∧ p 1 := forall_fin_succ.trans $ and_congr_right $ λ _, forall_fin_one lemma exists_fin_two {p : fin 2 → Prop} : (∃ i, p i) ↔ p 0 ∨ p 1 := -exists_fin_succ.trans $ or_congr_right exists_fin_one +exists_fin_succ.trans $ or_congr_right' exists_fin_one lemma fin_two_eq_of_eq_zero_iff {a b : fin 2} (h : a = 0 ↔ b = 0) : a = b := by { revert a b, simp [forall_fin_two] } diff --git a/src/data/set/basic.lean b/src/data/set/basic.lean index e21249b407058..3b29edd4d9b0a 100644 --- a/src/data/set/basic.lean +++ b/src/data/set/basic.lean @@ -703,7 +703,7 @@ h.elim (λ e, e.symm ▸ ha) (H _) theorem bex_insert_iff {P : α → Prop} {a : α} {s : set α} : (∃ x ∈ insert a s, P x) ↔ P a ∨ (∃ x ∈ s, P x) := -bex_or_left_distrib.trans $ or_congr_left bex_eq_left +bex_or_left_distrib.trans $ or_congr_left' bex_eq_left theorem ball_insert_iff {P : α → Prop} {a : α} {s : set α} : (∀ x ∈ insert a s, P x) ↔ P a ∧ (∀x ∈ s, P x) := diff --git a/src/logic/basic.lean b/src/logic/basic.lean index 8622fb4c48c8e..72400d1554c40 100644 --- a/src/logic/basic.lean +++ b/src/logic/basic.lean @@ -423,8 +423,8 @@ by simp only [and.left_comm, and.comm] lemma and_and_and_comm (a b c d : Prop) : (a ∧ b) ∧ c ∧ d ↔ (a ∧ c) ∧ b ∧ d := by rw [←and_assoc, @and.right_comm a, and_assoc] -lemma and.rotate : a ∧ b ∧ c ↔ b ∧ c ∧ a := -by simp only [and.left_comm, and.comm] +lemma and_rotate : a ∧ b ∧ c ↔ b ∧ c ∧ a := by simp only [and.left_comm, and.comm] +lemma and.rotate : a ∧ b ∧ c → b ∧ c ∧ a := and_rotate.1 theorem and_not_self_iff (a : Prop) : a ∧ ¬ a ↔ false := iff.intro (assume h, (h.right) (h.left)) (assume h, h.elim) @@ -466,12 +466,17 @@ by simp only [and.comm, ← and.congr_right_iff] lemma iff.or (h₁ : a ↔ b) (h₂ : c ↔ d) : a ∨ c ↔ b ∨ d := or_congr h₁ h₂ -theorem or_congr_left (h : a ↔ b) : a ∨ c ↔ b ∨ c := h.or iff.rfl - -theorem or_congr_right (h : b ↔ c) : a ∨ b ↔ a ∨ c := iff.rfl.or h +lemma or_congr_left' (h : a ↔ b) : a ∨ c ↔ b ∨ c := h.or iff.rfl +lemma or_congr_right' (h : b ↔ c) : a ∨ b ↔ a ∨ c := iff.rfl.or h theorem or.right_comm : (a ∨ b) ∨ c ↔ (a ∨ c) ∨ b := by rw [or_assoc, or_assoc, or_comm b] +lemma or_or_or_comm (a b c d : Prop) : (a ∨ b) ∨ c ∨ d ↔ (a ∨ c) ∨ b ∨ d := +by rw [←or_assoc, @or.right_comm a, or_assoc] + +lemma or_rotate : a ∨ b ∨ c ↔ b ∨ c ∨ a := by simp only [or.left_comm, or.comm] +lemma or.rotate : a ∨ b ∨ c → b ∨ c ∨ a := or_rotate.1 + theorem or_of_or_of_imp_of_imp (h₁ : a ∨ b) (h₂ : a → c) (h₃ : b → d) : c ∨ d := or.imp h₂ h₃ h₁ @@ -509,6 +514,20 @@ protected theorem decidable.not_imp_not [decidable a] : (¬ a → ¬ b) ↔ (b theorem not_imp_not : (¬ a → ¬ b) ↔ (b → a) := decidable.not_imp_not +-- See Note [decidable namespace] +protected lemma decidable.or_congr_left [decidable c] (h : ¬ c → (a ↔ b)) : a ∨ c ↔ b ∨ c := +by { rw [decidable.or_iff_not_imp_right, decidable.or_iff_not_imp_right], exact imp_congr_right h } + +lemma or_congr_left (h : ¬ c → (a ↔ b)) : a ∨ c ↔ b ∨ c := +decidable.or_congr_left h + +-- See Note [decidable namespace] +protected lemma decidable.or_congr_right [decidable a] (h : ¬ a → (b ↔ c)) : a ∨ b ↔ a ∨ c := +by { rw [decidable.or_iff_not_imp_left, decidable.or_iff_not_imp_left], exact imp_congr_right h } + +lemma or_congr_right (h : ¬ a → (b ↔ c)) : a ∨ b ↔ a ∨ c := +decidable.or_congr_right h + @[simp] theorem or_iff_left_iff_imp : (a ∨ b ↔ a) ↔ (b → a) := ⟨λ h hb, h.1 (or.inr hb), or_iff_left_of_imp⟩ @@ -878,13 +897,21 @@ exists_congr $ λ a, exists₄_congr $ h a end congr -variables {β : Sort*} {p q : α → Prop} {b : Prop} +variables {ι β : Sort*} {κ : ι → Sort*} {p q : α → Prop} {b : Prop} lemma forall_imp (h : ∀ a, p a → q a) : (∀ a, p a) → ∀ a, q a := λ h' a, h a (h' a) +lemma forall₂_imp {p q : Π i, κ i → Prop} (h : ∀ i j, p i j → q i j) : + (∀ i j, p i j) → ∀ i j, q i j := +forall_imp $ λ i, forall_imp $ h i + lemma Exists.imp (h : ∀ a, (p a → q a)) (p : ∃ a, p a) : ∃ a, q a := exists_imp_exists h p +lemma Exists₂.imp {p q : Π i, κ i → Prop} (h : ∀ i j, p i j → q i j) : + (∃ i j, p i j) → ∃ i j, q i j := +Exists.imp $ λ i, Exists.imp $ h i + lemma exists_imp_exists' {p : α → Prop} {q : β → Prop} (f : α → β) (hpq : ∀ a, p a → q (f a)) (hp : ∃ a, p a) : ∃ b, q b := exists.elim hp (λ a hp', ⟨_, hpq _ hp'⟩)