New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Algebra/MonoidAlgebra/NoZeroDivisors): NoZeroDivisors
instance on AddMonoidAlgebra
s
#6627
base: master
Are you sure you want to change the base?
Conversation
NoZeroDivisors
instance on AddMonoidAlgebra
s
variable [NoZeroDivisors R] [Add A] [LinearOrder A] [CovariantClass A A (· + ·) (· < ·)] | ||
[CovariantClass A A (Function.swap (· + ·)) (· < ·)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, Covariants.to_uniqueSums
uses the stronger set of conditions
[CovariantClass A A (· * ·) (· ≤ ·)] [CovariantClass A A (Function.swap (· * ·)) (· < ·)]
[ContravariantClass A A (· * ·) (· ≤ ·)]
In fact the last condition is equivalent to [CovariantClass A A (· + ·) (· < ·)]
in a linear order because a + c ≤ a + b → c ≤ b
is simply the contrapositive of b < c → a + b < a + c
.
I think the way to go is to change Covariants.to_uniqueSums
(and eq_and_eq_of_le_of_le_of_add_le
) to use the same conditions as here, prove NoZeroDivisors.uniqueSums
here instead, and derive NoZeroDivisors.biOrdered
from it. And I think we can make the proof of NoZeroDivisors.of_left_ordered
etc. a single line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could make UniqueSums
a typeclass and then NoZeroDivisors.biOrdered
would be inferInstance
.
Also, it should be trivial to add the MonoidAlgebra
version, but I think to_additive
doesn't work here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right: the plan was indeed to use UniqueSums
! I simply got stuck a few PRs before the port started... I'll fix it, but now is time to sleep for me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks and no worries! It's my bad that I already realized the PR is outdated but still mentioned it. No rush to update PR because I find that stuff around Covariant
/ContravariantClass
es should benefit from some refactoring utilizing Lean 4's loopy instances: there are lots of results of the shape A ↔ B, or A → B and B ∧ C → A. It would be nice to unify the assumptions of Left.add_eq_add_iff_eq_and_eq, Right.add_eq_add_iff_eq_and_eq, and your eq_and_eq_of_le_of_le_of_add_le, for example. I'll keep you updated!
(And I just realized UniqueProds and UniqueSums are indeed already instances; I confused them with UniqueMul and UniqueMul.
### Remarks | ||
To prove `NoZeroDivisors.biOrdered`, | ||
we use `CovariantClass` assumptions on `A`. In combination with `LinearOrder A`, these | ||
assumptions actually imply that `A` is cancellative. However, cancellativity alone in not enough. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assumptions actually imply that `A` is cancellative. However, cancellativity alone in not enough. | |
assumptions actually imply that `A` is cancellative. However, cancellativity alone is not enough. |
open Finsupp AddMonoidAlgebra | ||
|
||
example {R} [Ring R] [Nontrivial R] : | ||
∃ x y : AddMonoidAlgebra R (ZMod 2), x * y = 0 ∧ x ≠ 0 ∧ y ≠ 0 := by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this belong in Counterexamples/
?
The corresponding statement for a general product `f * g` is `AddMonoidAlgebra.mul_apply_of_le`. | ||
It is proved with a further `CovariantClass` assumption. -/ | ||
theorem single_mul_apply_of_le (r : R) (ft : ∀ a ∈ f.support, a ≤ t) : | ||
((AddMonoidAlgebra.single a r) * f) (a + t) = r * f t := by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
((AddMonoidAlgebra.single a r) * f) (a + t) = r * f t := by | |
(AddMonoidAlgebra.single a r * f) (a + t) = r * f t := by |
((AddMonoidAlgebra.single a r) * f) (a + b) = r * f b := | ||
single_mul_apply_of_le (A := Aᵒᵈ) _ fb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
((AddMonoidAlgebra.single a r) * f) (a + b) = r * f b := | |
single_mul_apply_of_le (A := Aᵒᵈ) _ fb | |
(AddMonoidAlgebra.single a r * f) (a + b) = r * f b := | |
single_mul_apply_of_le (A := Aᵒᵈ) _ fb |
Here, "top" is simply an upper bound for the elements of the support of the corresponding | ||
polynomial (e.g. the product is `0` if "top" is not a maximum). -/ | ||
theorem mul_apply_of_le (fa : ∀ i ∈ f.support, i ≤ a) (gt : ∀ i ∈ g.support, i ≤ t) : | ||
(f * g) (a + t) = f a * g t := by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(f * g) (a + t) = f a * g t := by | |
(f * g) (a + t) = f a * g t := by |
(f * g) (a + b) = f a * g b := | ||
mul_apply_of_le (A := Aᵒᵈ) fa gb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(f * g) (a + b) = f a * g b := | |
mul_apply_of_le (A := Aᵒᵈ) fa gb | |
(f * g) (a + b) = f a * g b := | |
mul_apply_of_le (A := Aᵒᵈ) fa gb |
mul_apply_of_le (A := Aᵒᵈ) fa gb | ||
|
||
theorem mul_apply_eq_zero_of_lt (fa : ∀ i ∈ f.support, a ≤ i) (gb : ∀ i ∈ g.support, b < i) : | ||
(f * g) (a + b) = 0 := by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(f * g) (a + b) = 0 := by | |
(f * g) (a + b) = 0 := by |
simp only [Finsupp.coe_zero, Pi.zero_apply] | ||
rw [mul_apply_of_le] <;> | ||
try exact Finset.le_max' _ | ||
refine mul_ne_zero_iff.mpr ⟨?_, ?_⟩ <;> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refine mul_ne_zero_iff.mpr ⟨?_, ?_⟩ <;> | |
refine mul_ne_zero ?_ ?_ <;> |
Porting the first part of mathlib3 #16157.
This contains the
NoZeroDivisor
instance onAddMonoidAlgebra
s that will trickle down to(Mv)Polynomial
s.