Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extensible push_neg tactic #21769

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
1f2c20c
feat: let `push_neg` replace `¬Finite` with `Infinite`
JovanGerb Feb 12, 2025
10ff78e
fixes
JovanGerb Feb 12, 2025
e219fb4
fix
JovanGerb Feb 12, 2025
c1b535d
fix
JovanGerb Feb 12, 2025
5cd85a9
fixes
JovanGerb Feb 12, 2025
613fb41
fix & clean up some proofs
JovanGerb Feb 12, 2025
a914490
feat: extensible `push` tactic generalizing `push_neg`
JovanGerb Feb 12, 2025
cf513e4
move location of files
JovanGerb Feb 13, 2025
cf24af5
allow for backwards lemmas
JovanGerb Feb 13, 2025
836671e
add the `push` tag to various lemmas
JovanGerb Feb 13, 2025
9e015aa
add a discharger option
JovanGerb Feb 13, 2025
7e1d6f6
test for `conv` mode
JovanGerb Feb 13, 2025
d9ea2a9
rename to `Lemmas.lean`
JovanGerb Feb 13, 2025
05864c1
now use the improved tactic
JovanGerb Feb 13, 2025
e128f2b
fix
JovanGerb Feb 13, 2025
e5992e3
fix
JovanGerb Feb 13, 2025
8039176
restore `assert_not_exists`
JovanGerb Feb 13, 2025
c4fe9e8
define attribute before tactic, to reduce import size
JovanGerb Feb 13, 2025
ffb7970
add docstrings
JovanGerb Feb 13, 2025
1d7e441
delete `Lemmas.lean`
JovanGerb Feb 13, 2025
f6ed5ae
add comment about loop
JovanGerb Feb 13, 2025
cb24e95
shake update
JovanGerb Feb 13, 2025
7b8de76
remove unneeded import
JovanGerb Feb 13, 2025
b0e1f42
move content from `Basic.lean` to `Push.lean`
JovanGerb Feb 13, 2025
a1c8071
doc
JovanGerb Feb 13, 2025
4748a7d
add test for pushing `Real.log`
JovanGerb Feb 13, 2025
60ed9f6
add `pushNeg` simproc_decl
JovanGerb Feb 13, 2025
fb366cc
feat: `push Forall` and `push lambda`
JovanGerb Feb 13, 2025
894bd4f
tag `push` lemmas about `∀` `∃` `∧` `∨` `fun`
JovanGerb Feb 13, 2025
f9ca6d3
lemmas for `pow`
JovanGerb Feb 13, 2025
112641f
tags for set complement
JovanGerb Feb 13, 2025
cd48f07
tags for `Set.mem`
JovanGerb Feb 13, 2025
ce4ff2a
`push_neg` for `Even` and `Odd`
JovanGerb Feb 13, 2025
cdc8193
fix elaborator
JovanGerb Feb 14, 2025
ab97461
revert noshake
JovanGerb Feb 14, 2025
5f04d0c
remove `@[push]` from not `Even` and `Odd`
JovanGerb Feb 14, 2025
1c786c7
tag lemmas about inverse/neg
JovanGerb Feb 15, 2025
53c45ef
tag lemmas about mem_insert and mem_singleton
JovanGerb Feb 15, 2025
c4dc45c
more tests
JovanGerb Feb 15, 2025
1b69d95
better syntax for notational constants, and push_neg for Filter
JovanGerb Feb 15, 2025
f414831
push_neg for `¬0 < a` -> a = 0
JovanGerb Feb 15, 2025
9c51ef5
.
JovanGerb Feb 15, 2025
6359b0a
some fixes
JovanGerb Feb 15, 2025
38776f9
add `not_nonneg_iff_eq_zero` for `Nat`
JovanGerb Feb 16, 2025
7fbf46e
Merge remote-tracking branch 'upstream' into push_neg-Finite
JovanGerb Feb 16, 2025
3356ee3
.
JovanGerb Feb 16, 2025
4b8cd19
fixes
JovanGerb Feb 16, 2025
1c1531e
tag `Finset.not_mem_compl`
JovanGerb Feb 16, 2025
510fe91
fix
JovanGerb Feb 16, 2025
37dcb9a
fix elaborator
JovanGerb Feb 16, 2025
78b8652
fix
JovanGerb Feb 16, 2025
637dfa9
fix
JovanGerb Feb 16, 2025
7bb1352
fix
JovanGerb Feb 16, 2025
5254bd3
add `not_zero_lt_iff`
JovanGerb Feb 16, 2025
a7bfbd4
update noshake
JovanGerb Feb 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Archive/Imo/Imo1988Q6.lean
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ theorem imo1988_q6 {a b : ℕ} (h : a * b + 1 ∣ a ^ 2 + b ^ 2) :
· -- Show that the claim is true if a = b.
intro x hx
suffices k ≤ 1 by
rw [Nat.le_add_one_iff, Nat.le_zero] at this
rw [Nat.le_one_iff_eq_zero_or_eq_one] at this
rcases this with (rfl | rfl)
· use 0; simp
· use 1; simp
Expand Down Expand Up @@ -292,7 +292,7 @@ example {a b : ℕ} (h : a * b ∣ a ^ 2 + b ^ 2 + 1) : 3 * a * b = a ^ 2 + b ^
omega
· -- Show the base case.
intro x y h h_base
obtain rfl | rfl : x = 0 ∨ x = 1 := by rwa [Nat.le_add_one_iff, Nat.le_zero] at h_base
obtain rfl | rfl : x = 0 ∨ x = 1 := Nat.le_one_iff_eq_zero_or_eq_one.mp h_base
· simp at h
· rw [mul_one, one_mul, add_right_comm] at h
have y_dvd : y ∣ y * k := dvd_mul_right y k
Expand Down
2 changes: 1 addition & 1 deletion Archive/Imo/Imo2013Q5.lean
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ theorem fixed_point_of_gt_1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 < x)
(x : ℝ) + (a ^ N - x : ℚ) ≤ f x + (a ^ N - x : ℚ) := by gcongr; exact H5 x hx
_ ≤ f x + f (a ^ N - x) := by gcongr; exact H5 _ h_big_enough
have hxp : 0 < x := by positivity
have hNp : 0 < N := by by_contra! H; rw [Nat.le_zero.mp H] at hN; linarith
have hNp : 0 < N := by by_contra! H; rw [H] at hN; linarith
have h2 :=
calc
f x + f (a ^ N - x) ≤ f (x + (a ^ N - x)) := H2 x (a ^ N - x) hxp (by positivity)
Expand Down
11 changes: 4 additions & 7 deletions Archive/Imo/Imo2024Q3.lean
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,14 @@ lemma apply_add_one_ne_of_apply_eq {i j : ℕ} (hi : N ≤ i) (hj : N ≤ j) (hi
(hc.apply_add_one_lt_of_apply_eq hj h ha.symm).ne'

lemma exists_infinite_setOf_apply_eq : ∃ m, {i | a i = m}.Infinite := by
by_contra hi
by_contra! hi
have hr : (Set.range a).Infinite := by
contrapose! hi with hr
rw [Set.not_infinite, ← Set.finite_coe_iff] at hr
rw [← Set.finite_coe_iff] at hr
obtain ⟨n, hn⟩ := Finite.exists_infinite_fiber (Set.rangeFactorization a)
rw [Set.infinite_coe_iff, Set.preimage] at hn
simp only [Set.mem_singleton_iff, Set.rangeFactorization, Subtype.ext_iff] at hn
exact ⟨↑n, hn⟩
simp only [not_exists, Set.not_infinite] at hi
have hinj : Set.InjOn (fun i ↦ Nat.nth (a · = i) 0 + 1) (Set.range a \ Set.Ico 0 (M a N)) := by
rintro _ ⟨⟨_, rfl⟩, hi⟩ _ ⟨⟨_, rfl⟩, hj⟩ h
simp only [Set.mem_diff, Set.mem_range, Set.mem_Ico, zero_le, true_and, not_lt] at hi hj
Expand Down Expand Up @@ -336,7 +335,7 @@ lemma bddAbove_setOf_k_lt_card : BddAbove {m | ∀ hf : {i | a i = m}.Finite, k

lemma k_pos : 0 < k a := by
by_contra! hn
apply nonpos_iff_eq_zero.mp hn ▸ hc.infinite_setOf_apply_eq_k
apply hn ▸ hc.infinite_setOf_apply_eq_k
convert Set.finite_empty
ext i
simp [(hc.pos i).ne']
Expand Down Expand Up @@ -627,7 +626,7 @@ lemma apply_add_one_eq_card_small_le_card_eq {i : ℕ} (hi : N' a N < i) (hib :
rw [Nat.lt_add_one_iff, ← Small] at hts
have ht0 : 0 < t := by
by_contra! h0
simp [nonpos_iff_eq_zero.mp h0, hc.apply_ne_zero] at htr
simp [h0, hc.apply_ne_zero] at htr
rw [← hc.infinite_setOf_apply_eq_iff_small ht0] at hts
rw [← Nat.count_eq_card_filter_range] at htr
constructor
Expand All @@ -643,11 +642,9 @@ lemma apply_add_one_eq_card_small_le_card_eq {i : ℕ} (hi : N' a N < i) (hib :
rw [← Small] at ht hu
have ht0 : 0 < t := by
by_contra! h0
simp only [nonpos_iff_eq_zero] at h0
simp [h0, hc.apply_ne_zero] at ht
have hu0 : 0 < u := by
by_contra! h0
simp only [nonpos_iff_eq_zero] at h0
simp [h0, hc.apply_ne_zero] at hu
rw [← hc.infinite_setOf_apply_eq_iff_small ht0] at ht
rw [← hc.infinite_setOf_apply_eq_iff_small hu0] at hu
Expand Down
6 changes: 2 additions & 4 deletions Archive/ZagierTwoSquares.lean
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ lemma zagierSet_lower_bound {x y z : ℕ} (h : (x, y, z) ∈ zagierSet k) : 0 <
rw [zagierSet, mem_setOf_eq] at h
refine ⟨?_, ?_, ?_⟩
all_goals
by_contra q
rw [not_lt, nonpos_iff_eq_zero] at q
by_contra! q
simp only [q, mul_zero, zero_mul, zero_add, add_zero] at h
· apply_fun (· % 4) at h
simp [mul_assoc, Nat.add_mod] at h
Expand Down Expand Up @@ -196,7 +195,6 @@ theorem Nat.Prime.sq_add_sq' {p : ℕ} [h : Fact p.Prime] (hp : p % 4 = 1) :
apply sq_add_sq_of_nonempty_fixedPoints
have key := (Equiv.Perm.card_fixedPoints_modEq (p := 2) (n := 1) (obvInvo_sq k)).symm.trans
(Equiv.Perm.card_fixedPoints_modEq (p := 2) (n := 1) (complexInvo_sq k))
contrapose key
rw [Set.not_nonempty_iff_eq_empty] at key
contrapose! key
simp_rw [k, key, Fintype.card_eq_zero, card_fixedPoints_eq_one]
decide
2 changes: 1 addition & 1 deletion Counterexamples/Phillips.lean
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ theorem countable_ne (Hcont : #ℝ = ℵ₁) (φ : (DiscreteCopy ℝ →ᵇ ℝ)
⋃ y ∈ φ.toBoundedAdditiveMeasure.discreteSupport, {x | y ∈ spf Hcont x} := by
intro x hx
dsimp at hx
rw [← Ne, ← nonempty_iff_ne_empty] at hx
push_neg at hx
simp only [exists_prop, mem_iUnion, mem_setOf_eq]
exact hx
apply Countable.mono (Subset.trans A B)
Expand Down
3 changes: 2 additions & 1 deletion Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5249,7 +5249,8 @@ import Mathlib.Tactic.ProdAssoc
import Mathlib.Tactic.ProjectionNotation
import Mathlib.Tactic.Propose
import Mathlib.Tactic.ProxyType
import Mathlib.Tactic.PushNeg
import Mathlib.Tactic.Push
import Mathlib.Tactic.Push.Attr
import Mathlib.Tactic.Qify
import Mathlib.Tactic.RSuffices
import Mathlib.Tactic.Recall
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/BigOperators/Finprod.lean
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ theorem MonoidHom.map_finprod {f : α → M} (g : M →* N) (hf : (mulSupport f)
g (∏ᶠ i, f i) = ∏ᶠ i, g (f i) :=
g.map_finprod_plift f <| hf.preimage Equiv.plift.injective.injOn

@[to_additive]
@[to_additive (attr := push)]
theorem finprod_pow (hf : (mulSupport f).Finite) (n : ℕ) : (∏ᶠ i, f i) ^ n = ∏ᶠ i, f i ^ n :=
(powMonoidHom n).map_finprod hf

Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/BigOperators/Group/Finset/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ theorem prod_induction_nonempty {M : Type*} [CommMonoid M] (f : α → M) (p : M
Multiset.prod_induction_nonempty p hom (by simp [nonempty_iff_ne_empty.mp nonempty])
(Multiset.forall_mem_map_iff.mpr base)

@[to_additive]
@[to_additive (attr := push ←)]
theorem prod_pow (s : Finset α) (n : ℕ) (f : α → β) : ∏ x ∈ s, f x ^ n = (∏ x ∈ s, f x) ^ n :=
Multiset.prod_map_pow

Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/CharP/MixedCharZero.lean
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ theorem isEmpty_algebraRat_iff_mixedCharZero [CharZero R] :
IsEmpty (Algebra ℚ R) ↔ ∃ p > 0, MixedCharZero R p := by
rw [← not_iff_not]
push_neg
rw [not_isEmpty_iff, ← EqualCharZero.iff_not_mixedCharZero]
rw [← EqualCharZero.iff_not_mixedCharZero]
apply EqualCharZero.nonempty_algebraRat_iff

/-!
Expand Down
1 change: 1 addition & 0 deletions Mathlib/Algebra/Group/Action/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ variable {M}
section Monoid
variable [Monoid N] [MulAction M N] [IsScalarTower M N N] [SMulCommClass M N N]

@[push]
lemma smul_pow (r : M) (x : N) : ∀ n, (r • x) ^ n = r ^ n • x ^ n
| 0 => by simp
| n + 1 => by rw [pow_succ', smul_pow _ _ n, smul_mul_smul_comm, ← pow_succ', ← pow_succ']
Expand Down
18 changes: 9 additions & 9 deletions Mathlib/Algebra/Group/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ variable [CommMonoid M] {x y z : M}
theorem inv_unique (hy : x * y = 1) (hz : x * z = 1) : y = z :=
left_inv_eq_right_inv (Trans.trans (mul_comm _ _) hy) hz

@[to_additive nsmul_add] lemma mul_pow (a b : M) : ∀ n, (a * b) ^ n = a ^ n * b ^ n
@[to_additive (attr := push) nsmul_add] lemma mul_pow (a b : M) : ∀ n, (a * b) ^ n = a ^ n * b ^ n
| 0 => by rw [pow_zero, pow_zero, pow_zero, one_mul]
| n + 1 => by rw [pow_succ', pow_succ', pow_succ', mul_pow, mul_mul_mul_comm]

Expand Down Expand Up @@ -395,7 +395,7 @@ theorem one_div_mul_one_div_rev : 1 / a * (1 / b) = 1 / (b * a) := by simp
@[to_additive]
theorem inv_div_left : a⁻¹ / b = (b * a)⁻¹ := by simp

@[to_additive (attr := simp)]
@[to_additive (attr := simp, push)]
theorem inv_div : (a / b)⁻¹ = b / a := by simp

@[to_additive]
Expand All @@ -413,7 +413,7 @@ instance (priority := 100) DivisionMonoid.toDivInvOneMonoid : DivInvOneMonoid α
{ DivisionMonoid.toDivInvMonoid with
inv_one := by simpa only [one_div, inv_inv] using (inv_div (1 : α) 1).symm }

@[to_additive (attr := simp)]
@[to_additive (attr := simp, push, push ←)]
lemma inv_pow (a : α) : ∀ n : ℕ, a⁻¹ ^ n = (a ^ n)⁻¹
| 0 => by rw [pow_zero, pow_zero, inv_one]
| n + 1 => by rw [pow_succ', pow_succ, inv_pow _ n, mul_inv_rev]
Expand All @@ -438,12 +438,12 @@ lemma zpow_neg (a : α) : ∀ n : ℤ, a ^ (-n) = (a ^ n)⁻¹
lemma mul_zpow_neg_one (a b : α) : (a * b) ^ (-1 : ℤ) = b ^ (-1 : ℤ) * a ^ (-1 : ℤ) := by
simp only [zpow_neg, zpow_one, mul_inv_rev]

@[to_additive zsmul_neg]
@[to_additive (attr := push ←) zsmul_neg]
lemma inv_zpow (a : α) : ∀ n : ℤ, a⁻¹ ^ n = (a ^ n)⁻¹
| (n : ℕ) => by rw [zpow_natCast, zpow_natCast, inv_pow]
| .negSucc n => by rw [zpow_negSucc, zpow_negSucc, inv_pow]

@[to_additive (attr := simp) zsmul_neg']
@[to_additive (attr := simp, push) zsmul_neg']
lemma inv_zpow' (a : α) (n : ℤ) : a⁻¹ ^ n = a ^ (-n) := by rw [inv_zpow, zpow_neg]

@[to_additive nsmul_zero_sub]
Expand Down Expand Up @@ -514,7 +514,7 @@ variable [DivisionCommMonoid α] (a b c d : α)

attribute [local simp] mul_assoc mul_comm mul_left_comm div_eq_mul_inv

@[to_additive neg_add]
@[to_additive (attr := push high) neg_add]
theorem mul_inv : (a * b)⁻¹ = a⁻¹ * b⁻¹ := by simp

@[to_additive]
Expand Down Expand Up @@ -589,11 +589,11 @@ theorem mul_div_mul_comm : a * b / (c * d) = a / c * (b / d) := by simp
| (n : ℕ) => by simp_rw [zpow_natCast, mul_pow]
| .negSucc n => by simp_rw [zpow_negSucc, ← inv_pow, mul_inv, mul_pow]

@[to_additive nsmul_sub]
@[to_additive (attr := push) nsmul_sub]
lemma div_pow (a b : α) (n : ℕ) : (a / b) ^ n = a ^ n / b ^ n := by
simp only [div_eq_mul_inv, mul_pow, inv_pow]

@[to_additive zsmul_sub]
@[to_additive (attr := push) zsmul_sub]
lemma div_zpow (a b : α) (n : ℤ) : (a / b) ^ n = a ^ n / b ^ n := by
simp only [div_eq_mul_inv, mul_zpow, inv_zpow]

Expand Down Expand Up @@ -799,7 +799,7 @@ theorem leftInverse_inv_mul_mul_right (c : G) :
@[to_additive (attr := simp) natAbs_nsmul_eq_zero]
lemma pow_natAbs_eq_one : a ^ n.natAbs = 1 ↔ a ^ n = 1 := by cases n <;> simp

@[to_additive sub_nsmul]
@[to_additive (attr := push) sub_nsmul]
lemma pow_sub (a : G) {m n : ℕ} (h : n ≤ m) : a ^ (m - n) = a ^ m * (a ^ n)⁻¹ :=
eq_mul_inv_of_mul_eq <| by rw [← pow_add, Nat.sub_add_cancel h]

Expand Down
10 changes: 6 additions & 4 deletions Mathlib/Algebra/Group/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Mathlib.Algebra.Group.Operations
import Mathlib.Logic.Function.Defs
import Mathlib.Tactic.Simps.Basic
import Mathlib.Tactic.OfNat
import Mathlib.Tactic.Push.Attr
import Batteries.Logic

/-!
Expand Down Expand Up @@ -597,7 +598,7 @@ lemma pow_three' (a : M) : a ^ 3 = a * a * a := by rw [pow_succ, pow_two]
lemma pow_three (a : M) : a ^ 3 = a * (a * a) := by rw [pow_succ', pow_two]

-- the attributes are intentionally out of order.
@[to_additive nsmul_zero, simp] lemma one_pow : ∀ n, (1 : M) ^ n = 1
@[to_additive (attr := push) nsmul_zero, simp] lemma one_pow : ∀ n, (1 : M) ^ n = 1
| 0 => pow_zero _
| n + 1 => by rw [pow_succ, one_pow, one_mul]

Expand All @@ -609,7 +610,8 @@ lemma pow_add (a : M) (m : ℕ) : ∀ n, a ^ (m + n) = a ^ m * a ^ n
@[to_additive] lemma pow_mul_comm (a : M) (m n : ℕ) : a ^ m * a ^ n = a ^ n * a ^ m := by
rw [← pow_add, ← pow_add, Nat.add_comm]

@[to_additive mul_nsmul] lemma pow_mul (a : M) (m : ℕ) : ∀ n, a ^ (m * n) = (a ^ m) ^ n
@[to_additive (attr := push ←) mul_nsmul]
lemma pow_mul (a : M) (m : ℕ) : ∀ n, a ^ (m * n) = (a ^ m) ^ n
| 0 => by rw [Nat.mul_zero, pow_zero, pow_zero]
| n + 1 => by rw [Nat.mul_succ, pow_add, pow_succ, pow_mul]

Expand Down Expand Up @@ -727,7 +729,7 @@ class InvolutiveInv (G : Type*) extends Inv G where

variable [InvolutiveInv G]

@[to_additive (attr := simp)]
@[to_additive (attr := simp, push)]
theorem inv_inv (a : G) : a⁻¹⁻¹ = a :=
InvolutiveInv.inv_inv _

Expand Down Expand Up @@ -981,7 +983,7 @@ section DivisionMonoid

variable [DivisionMonoid G] {a b : G}

@[to_additive (attr := simp) neg_add_rev]
@[to_additive (attr := simp, push) neg_add_rev]
theorem mul_inv_rev (a b : G) : (a * b)⁻¹ = b⁻¹ * a⁻¹ :=
DivisionMonoid.mul_inv_rev _ _

Expand Down
10 changes: 5 additions & 5 deletions Mathlib/Algebra/Group/Pi/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ instance instOne [∀ i, One <| f i] : One (∀ i : I, f i) :=
theorem one_apply [∀ i, One <| f i] : (1 : ∀ i, f i) i = 1 :=
rfl

@[to_additive]
@[to_additive (attr := push ←)]
theorem one_def [∀ i, One <| f i] : (1 : ∀ i, f i) = fun _ => 1 :=
rfl

Expand All @@ -72,7 +72,7 @@ instance instMul [∀ i, Mul <| f i] : Mul (∀ i : I, f i) :=
theorem mul_apply [∀ i, Mul <| f i] : (x * y) i = x i * y i :=
rfl

@[to_additive]
@[to_additive (attr := push ←)]
theorem mul_def [∀ i, Mul <| f i] : x * y = fun i => x i * y i :=
rfl

Expand All @@ -95,7 +95,7 @@ instance instPow [∀ i, Pow (f i) β] : Pow (∀ i, f i) β :=
theorem pow_apply [∀ i, Pow (f i) β] (x : ∀ i, f i) (b : β) (i : I) : (x ^ b) i = x i ^ b :=
rfl

@[to_additive (attr := to_additive) (reorder := 5 6) smul_def]
@[to_additive (attr := push ←, to_additive) (reorder := 5 6) smul_def]
theorem pow_def [∀ i, Pow (f i) β] (x : ∀ i, f i) (b : β) : x ^ b = fun i => x i ^ b :=
rfl

Expand All @@ -116,7 +116,7 @@ instance instInv [∀ i, Inv <| f i] : Inv (∀ i : I, f i) :=
theorem inv_apply [∀ i, Inv <| f i] : x⁻¹ i = (x i)⁻¹ :=
rfl

@[to_additive]
@[to_additive (attr := push ←)]
theorem inv_def [∀ i, Inv <| f i] : x⁻¹ = fun i => (x i)⁻¹ :=
rfl

Expand All @@ -135,7 +135,7 @@ instance instDiv [∀ i, Div <| f i] : Div (∀ i : I, f i) :=
theorem div_apply [∀ i, Div <| f i] : (x / y) i = x i / y i :=
rfl

@[to_additive]
@[to_additive (attr := push ←)]
theorem div_def [∀ i, Div <| f i] : x / y = fun i => x i / y i :=
rfl

Expand Down
13 changes: 4 additions & 9 deletions Mathlib/Algebra/Group/Pointwise/Finset/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1008,12 +1008,8 @@ set_option push_neg.use_distrib true in
constructor
· contrapose!
rintro (hs | rfl)
-- TODO: The `nonempty_iff_ne_empty` would be unnecessary if `push_neg` knew how to simplify
-- `s ≠ ∅` to `s.Nonempty` when `s : Finset α`.
-- See https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/push_neg.20extensibility
· exact nonempty_iff_ne_empty.1 (nonempty_iff_ne_empty.2 hs).pow
· rw [← nonempty_iff_ne_empty]
simp
· exact hs.pow
· simp
· rintro ⟨rfl, hn⟩
exact empty_pow hn

Expand Down Expand Up @@ -1168,9 +1164,8 @@ set_option push_neg.use_distrib true in
constructor
· contrapose!
rintro (hs | rfl)
· exact nonempty_iff_ne_empty.1 (nonempty_iff_ne_empty.2 hs).zpow
· rw [← nonempty_iff_ne_empty]
simp
· exact hs.zpow
· simp
· rintro ⟨rfl, hn⟩
exact empty_zpow hn

Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/GroupWithZero/Action/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ theorem MulDistribMulAction.toMonoidHom_apply (r : M) (x : A) :
MulDistribMulAction.toMonoidHom A r x = r • x :=
rfl

@[simp] lemma smul_pow' (r : M) (x : A) (n : ℕ) : r • x ^ n = (r • x) ^ n :=
@[simp, push ←] lemma smul_pow' (r : M) (x : A) (n : ℕ) : r • x ^ n = (r • x) ^ n :=
(MulDistribMulAction.toMonoidHom _ _).map_pow _ _

end
Expand Down
7 changes: 4 additions & 3 deletions Mathlib/Algebra/Lie/Submodule.lean
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,10 @@ instance [Nontrivial M] : Nontrivial (LieSubmodule R L M) :=
theorem nontrivial_iff_ne_bot {N : LieSubmodule R L M} : Nontrivial N ↔ N ≠ ⊥ := by
constructor <;> contrapose!
· rintro rfl
⟨⟨m₁, h₁ : m₁ ∈ (⊥ : LieSubmodule R L M)⟩, ⟨m₂, h₂ : m₂ ∈ (⊥ : LieSubmodule R L M)⟩, h₁₂⟩
simp [(LieSubmodule.mem_bot _).mp h₁, (LieSubmodule.mem_bot _).mp h₂] at h₁₂
· rw [not_nontrivial_iff_subsingleton, LieSubmodule.eq_bot_iff]
constructor
rintro ⟨m₁, h₁ : m₁ ∈ (⊥ : LieSubmodule R L M)⟩ ⟨m₂, h₂ : m₂ ∈ (⊥ : LieSubmodule R L M)⟩
simp only [(LieSubmodule.mem_bot _).mp h₁, (LieSubmodule.mem_bot _).mp h₂]
· rw [LieSubmodule.eq_bot_iff]
rintro ⟨h⟩ m hm
simpa using h ⟨m, hm⟩ ⟨_, N.zero_mem⟩

Expand Down
3 changes: 1 addition & 2 deletions Mathlib/Algebra/Lie/Weights/Linear.lean
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ lemma exists_nontrivial_weightSpace_of_isNilpotent [Field k] [LieAlgebra k L] [M
[IsTriangularizable k L M] [Nontrivial M] :
∃ χ : Module.Dual k L, Nontrivial (weightSpace M χ) := by
obtain ⟨χ⟩ : Nonempty (Weight k L M) := by
by_contra contra
rw [not_nonempty_iff] at contra
by_contra! contra
simpa only [iSup_of_empty, bot_ne_top] using LieModule.iSup_genWeightSpace_eq_top' k L M
obtain ⟨m, hm₀, hm⟩ := exists_forall_lie_eq_smul k L M χ
simp only [LieSubmodule.nontrivial_iff_ne_bot, LieSubmodule.eq_bot_iff, Weight.coe_coe, ne_eq,
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/Module/DedekindDomain.lean
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ theorem isInternal_prime_power_torsion [DecidableEq (Ideal R)] [Module.Finite R
have hM' := Module.isTorsionBySet_annihilator_top R M
have hI := Submodule.annihilator_top_inter_nonZeroDivisors hM
refine isInternal_prime_power_torsion_of_is_torsion_by_ideal ?_ hM'
rw [← Set.nonempty_iff_ne_empty] at hI; rw [Submodule.ne_bot_iff]
push_neg at hI; rw [Submodule.ne_bot_iff]
obtain ⟨x, H, hx⟩ := hI; exact ⟨x, H, nonZeroDivisors.ne_zero hx⟩

/-- A finitely generated torsion module over a Dedekind domain is an internal direct sum of its
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/Order/Antidiag/Nat.lean
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ theorem mem_finMulAntidiag {d n : ℕ} {f : Fin d → ℕ} :
refine ⟨fun i ↦ ⟨f i, ?_⟩, rfl, funext fun _ => rfl⟩
apply Nat.pos_of_ne_zero
exact Finset.prod_ne_zero_iff.mp h.ne.symm _ (mem_univ _)
· simp only [not_lt, nonpos_iff_eq_zero] at h
· push_neg at h
simp only [h, not_mem_empty, ne_eq, not_true_eq_false, and_false]

@[simp]
Expand Down
Loading