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

Commit c6014bd

Browse files
committed
feat(algebra/parity): more general odd.pos (#15186)
The old version of this lemma (added in #13040) was only for ℕ and didn't allow dot notation. We remove this and add a version for `canonically_ordered_comm_semiring`s, and if the definition of `odd` changes, this will also work for `canononically_ordered_add_monoid`s. Co-authored-by: Eric Rodriguez <37984851+ericrbg@users.noreply.github.com>
1 parent ede73b2 commit c6014bd

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

archive/imo/imo1998_q2.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ theorem imo1998_q2 [fintype J] [fintype C]
201201
(hk : ∀ (p : judge_pair J), p.distinct → (agreed_contestants r p).card ≤ k) :
202202
(b - 1) / (2 * b) ≤ k / a :=
203203
begin
204-
rw clear_denominators ha (nat.pos_of_odd hb),
204+
rw clear_denominators ha hb.pos,
205205
obtain ⟨z, hz⟩ := hb, rw hz at hJ, rw hz,
206206
have h := le_trans (A_card_lower_bound r hJ) (A_card_upper_bound r hk),
207207
rw [hC, hJ] at h,

src/algebra/parity.lean

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,21 @@ lemma odd.neg_one_pow (h : odd n) : (-1 : α) ^ n = -1 := by rw [h.neg_pow, one_
241241

242242
end monoid
243243

244+
section canonically_ordered_comm_semiring
245+
246+
variables [canonically_ordered_comm_semiring α]
247+
248+
-- this holds more generally in a `canonically_ordered_add_monoid` if we refactor `odd` to use
249+
-- either `2 • t` or `t + t` instead of `2 * t`.
250+
lemma odd.pos [nontrivial α] {n : α} (hn : odd n) : 0 < n :=
251+
begin
252+
obtain ⟨k, rfl⟩ := hn,
253+
rw [pos_iff_ne_zero, ne.def, add_eq_zero_iff, not_and'],
254+
exact λ h, (one_ne_zero h).elim
255+
end
256+
257+
end canonically_ordered_comm_semiring
258+
244259
section ring
245260
variables [ring α] {a b : α} {n : ℕ}
246261

src/data/nat/parity.lean

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ begin
7272
one_ne_zero, and_self] },
7373
end
7474

75-
lemma pos_of_odd (h : odd n) : 0 < n :=
76-
by { obtain ⟨k, rfl⟩ := h, exact succ_pos' }
77-
7875
@[simp] theorem two_dvd_ne_zero : ¬ 2 ∣ n ↔ n % 2 = 1 :=
7976
even_iff_two_dvd.symm.not.trans not_even_iff
8077

0 commit comments

Comments
 (0)