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

Commit 2caf479

Browse files
committed
feat(data/matrix/basic): add bit0, bit1 lemmas (#2987)
Based on a conversation in https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/Matrix.20equality.20by.20extensionality we define simp lemmas for matrices represented by numerals. This should result in better representation of scalar multiples of `one_val : matrix n n a`. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
1 parent 3ca4c27 commit 2caf479

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/data/matrix/basic.lean

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/-
22
Copyright (c) 2018 Ellen Arlt. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
4-
Authors: Ellen Arlt, Blair Shi, Sean Leather, Mario Carneiro, Johan Commelin
4+
Authors: Ellen Arlt, Blair Shi, Sean Leather, Mario Carneiro, Johan Commelin, Scott Morrison, Yakov Pechersky
55
-/
66
import algebra.pi_instances
77
/-!
@@ -102,6 +102,13 @@ diagonal_val_ne'
102102
end one
103103
end diagonal
104104

105+
@[simp] lemma bit0_apply_apply [has_add α] (M : matrix n n α) (i : n) (j : n) :
106+
(bit0 M) i j = bit0 (M i j) := rfl
107+
108+
@[simp] lemma bit1_apply_apply [decidable_eq n] [semiring α] (M : matrix n n α) (i : n) (j : n) :
109+
(bit1 M) i j = if i = j then bit1 (M i j) else bit0 (M i j) :=
110+
by dsimp [bit1]; by_cases i = j; simp [h]
111+
105112
@[simp] theorem diagonal_add [decidable_eq n] [add_monoid α] (d₁ d₂ : n → α) :
106113
diagonal d₁ + diagonal d₂ = diagonal (λ i, d₁ i + d₂ i) :=
107114
by ext i j; by_cases i = j; simp [h]

0 commit comments

Comments
 (0)