Skip to content

Commit

Permalink
feat(algebra/order/ring): add odd_neg, odd_abs, generalize dvd/abs le…
Browse files Browse the repository at this point in the history
…mmas (#9362)
  • Loading branch information
Ruben-VandeVelde committed Sep 26, 2021
1 parent def1c02 commit 83470af
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/algebra/order/ring.lean
Expand Up @@ -1278,6 +1278,10 @@ begin
mul_one, mul_neg_eq_neg_mul_symm, neg_add_rev, neg_neg],
end

end linear_ordered_comm_ring
section
variables [ring α] [linear_order α] {a b : α}

@[simp] lemma abs_dvd (a b : α) : abs a ∣ b ↔ a ∣ b :=
by { cases abs_choice a with h h; simp only [h, neg_dvd] }

Expand All @@ -1296,6 +1300,15 @@ lemma abs_dvd_abs (a b : α) : abs a ∣ abs b ↔ a ∣ b :=
lemma even_abs {a : α} : even (abs a) ↔ even a :=
dvd_abs _ _

lemma odd_abs {a : α} : odd (abs a) ↔ odd a :=
by { cases abs_choice a with h h; simp only [h, odd_neg] }

end

section linear_ordered_comm_ring

variables [linear_ordered_comm_ring α]

/-- Pullback a `linear_ordered_comm_ring` under an injective map.
See note [reducible non-instances]. -/
@[reducible]
Expand Down
11 changes: 11 additions & 0 deletions src/algebra/ring/basic.lean
Expand Up @@ -841,6 +841,17 @@ end
@[simp] theorem even_neg (a : α) : even (-a) ↔ even a :=
dvd_neg _ _

lemma odd.neg {a : α} (hp : odd a) : odd (-a) :=
begin
obtain ⟨k, hk⟩ := hp,
use -(k + 1),
rw [mul_neg_eq_neg_mul_symm, mul_add, neg_add, add_assoc, two_mul (1 : α), neg_add,
neg_add_cancel_right, ←neg_add, hk],
end

@[simp] lemma odd_neg (a : α) : odd (-a) ↔ odd a :=
⟨λ h, neg_neg a ▸ h.neg, odd.neg⟩

end ring

section comm_ring
Expand Down

0 comments on commit 83470af

Please sign in to comment.