Skip to content

Commit

Permalink
feat(algebra/ring): ite_mul_one and ite_mul_zero_... (#3217)
Browse files Browse the repository at this point in the history
Three simple lemmas about if statements involving multiplication, useful while rewriting.



Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
  • Loading branch information
semorrison and semorrison committed Jun 29, 2020
1 parent 0065d99 commit 413b53b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/algebra/group/basic.lean
Expand Up @@ -11,6 +11,16 @@ import tactic.protected

universe u

section monoid
variables {M : Type u} [monoid M]

@[to_additive]
lemma ite_mul_one {P : Prop} [decidable P] {a b : M} :
ite P (a * b) 1 = ite P a 1 * ite P b 1 :=
by { by_cases h : P; simp [h], }

end monoid

section comm_semigroup
variables {G : Type u} [comm_semigroup G]

Expand Down
8 changes: 8 additions & 0 deletions src/algebra/ring.lean
Expand Up @@ -158,6 +158,14 @@ by simp
(if P then 1 else 0) * a = if P then a else 0 :=
by simp

lemma ite_mul_zero_left {α : Type*} [mul_zero_class α] (P : Prop) [decidable P] (a b : α) :
ite P (a * b) 0 = ite P a 0 * b :=
by { by_cases h : P; simp [h], }

lemma ite_mul_zero_right {α : Type*} [mul_zero_class α] (P : Prop) [decidable P] (a b : α) :
ite P (a * b) 0 = a * ite P b 0 :=
by { by_cases h : P; simp [h], }

variable (α)

/-- Either zero and one are nonequal in a semiring, or the semiring is the zero ring. -/
Expand Down

0 comments on commit 413b53b

Please sign in to comment.