Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 31cb3c1

Browse files
committed
chore(algebra/group_with_zero/basic): generalize units.exists_iff_ne_zero to arbitrary propositions (#12439)
This adds a more powerful version of this lemma that allows an existential to be replaced with one over the underlying group with zero. The naming matches `subtype.exists` and `subtype.exists'`, while the trailing zero matches `units.mk0`.
1 parent 6e94c53 commit 31cb3c1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/algebra/group_with_zero/basic.lean

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,18 @@ eq_inv_of_mul_left_eq_one u.inv_mul
690690
units.mk0 a ha = units.mk0 b hb ↔ a = b :=
691691
⟨λ h, by injection h, λ h, units.ext h⟩
692692

693+
/-- In a group with zero, an existential over a unit can be rewritten in terms of `units.mk0`. -/
694+
lemma exists0 {p : G₀ˣ → Prop} : (∃ g : G₀ˣ, p g) ↔ ∃ (g : G₀) (hg : g ≠ 0), p (units.mk0 g hg) :=
695+
⟨λ ⟨g, pg⟩, ⟨g, g.ne_zero, (g.mk0_coe g.ne_zero).symm ▸ pg⟩, λ ⟨g, hg, pg⟩, ⟨units.mk0 g hg, pg⟩⟩
696+
697+
/-- An alternative version of `units.exists0`. This one is useful if Lean cannot
698+
figure out `p` when using `units.exists0` from right to left. -/
699+
lemma exists0' {p : Π g : G₀, g ≠ 0Prop} :
700+
(∃ (g : G₀) (hg : g ≠ 0), p g hg) ↔ ∃ g : G₀ˣ, p g g.ne_zero :=
701+
iff.trans (by simp_rw [coe_mk0]) exists0.symm
702+
693703
@[simp] lemma exists_iff_ne_zero {x : G₀} : (∃ u : G₀ˣ, ↑u = x) ↔ x ≠ 0 :=
694-
⟨λ ⟨u, hu⟩, hu ▸ u.ne_zero, assume hx, ⟨mk0 x hx, rfl⟩⟩
704+
by simp [exists0]
695705

696706
lemma _root_.group_with_zero.eq_zero_or_unit (a : G₀) :
697707
a = 0 ∨ ∃ u : G₀ˣ, a = u :=

0 commit comments

Comments
 (0)