Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
bace355
first attempt
j-loreaux Jun 28, 2023
ae1a006
try to fix
j-loreaux Jun 29, 2023
5f796d6
Merge branch 'master' into j-loreaux/ppow
mans0954 Apr 22, 2024
9380937
Fix up
mans0954 Apr 23, 2024
f4a060f
Lint
mans0954 Apr 23, 2024
9dafe98
Lint
mans0954 Apr 23, 2024
85a19cc
Remove duplicate (additive) ext
mans0954 Apr 23, 2024
74b1096
Import all files
mans0954 Apr 23, 2024
aad455e
remove heartbeat bumps, except one in algebraic geometry
j-loreaux Apr 23, 2024
89bb578
remove unused arguments
j-loreaux Apr 23, 2024
60dbead
add docstrings
j-loreaux Apr 23, 2024
2f49acb
Merge pull request #12355 from leanprover-community/mans0954/j-loreau…
mans0954 Apr 23, 2024
745e4a9
Merge branch 'master' into j-loreaux/ppow
j-loreaux Mar 3, 2025
76c0d17
fix to_additive
j-loreaux Mar 3, 2025
0963910
fix import?
j-loreaux Mar 3, 2025
f9b0826
:Merge branch 'master' into j-loreaux/ppow
j-loreaux Mar 3, 2025
950dd9f
fix all?
j-loreaux Mar 4, 2025
fe85b6a
namespace lemmas in `PNatPowAssoc` to avoid conflicts
j-loreaux Mar 4, 2025
d7d20f7
shake
j-loreaux Mar 4, 2025
e1c7d45
Merge remote-tracking branch 'upstream/master' into HEAD
pechersky Jun 18, 2026
1927358
Ext.lean
pechersky Jun 18, 2026
972d5d2
mk_all
pechersky Jun 18, 2026
ea0af54
fix zmod
pechersky Jun 18, 2026
a3be18b
nonunital center fast_instance hack
pechersky Jun 18, 2026
0b5b156
cleanup
pechersky Jun 18, 2026
fe2b397
another fix, don't copy data
pechersky Jun 18, 2026
c123b67
lints
pechersky Jun 18, 2026
fdde4b1
more proof fix
pechersky Jun 18, 2026
c76c306
fix merge
pechersky Jun 18, 2026
0d6cc7d
factor out Pow instance to help bootstrap
pechersky Jun 22, 2026
72ed034
module system
pechersky Jun 22, 2026
81e818c
preparatory shuffle
pechersky Jun 22, 2026
fbafdd9
InjSurj update
pechersky Jun 22, 2026
069661c
InjSurj update
pechersky Jun 22, 2026
f4d2fae
InjSurj update
pechersky Jun 22, 2026
dc2506b
order lemmas
pechersky Jun 22, 2026
56c665b
ring order
pechersky Jun 22, 2026
69c0792
subsemigroup
pechersky Jun 22, 2026
f52a35f
ulift
pechersky Jun 22, 2026
7a1d264
transfer
pechersky Jun 22, 2026
e066182
opposite
pechersky Jun 22, 2026
18ce684
linearorderedcommmonoidwithzero
pechersky Jun 22, 2026
5d6858e
Pi
pechersky Jun 22, 2026
4bac04f
dfinsupp
pechersky Jun 22, 2026
0fadffc
Hom instances
pechersky Jun 23, 2026
c40d8a2
long file FIXME
pechersky Jun 23, 2026
f47f8f6
ulift with zero
pechersky Jun 23, 2026
dd63c5c
remove assert_not_exists
pechersky Jun 23, 2026
46ec856
Rat psmul and ppow
pechersky Jun 23, 2026
5c52583
Submonoid
pechersky Jun 23, 2026
e8fea58
fix order
pechersky Jun 23, 2026
899d3d1
group Con
pechersky Jun 23, 2026
679294d
Field
pechersky Jun 23, 2026
07a464b
PNat: move Add and recOn earlier
pechersky Jun 23, 2026
63da001
injsurj fix order
pechersky Jun 23, 2026
3a5af0c
pointwise finset
pechersky Jun 23, 2026
adf9729
injsurj fix order and formatting
pechersky Jun 23, 2026
6ac546a
subgroup
pechersky Jun 23, 2026
79110fb
ring injsurj arg order and lemma order
pechersky Jun 23, 2026
1f06ecf
Kleene
pechersky Jun 23, 2026
deeb99e
finsupp
pechersky Jun 23, 2026
0a9c0ae
namespacing
pechersky Jun 23, 2026
7c52096
order lemmas and nonneg instances
pechersky Jun 23, 2026
085189a
remove dupl lemma
pechersky Jun 23, 2026
5e3055f
fix field args
pechersky Jun 23, 2026
61914bf
fix lemma rename
pechersky Jun 23, 2026
fd4f64b
nonunitalsubsemiring
pechersky Jun 23, 2026
94edf05
subsemiring
pechersky Jun 23, 2026
6277243
nonunitalsubring
pechersky Jun 23, 2026
c7dd30b
nonneg semifield -- no coe_ lemmas, it is rfl
pechersky Jun 23, 2026
803dd8e
subring
pechersky Jun 23, 2026
6c4fa25
reduce imports
pechersky Jun 23, 2026
c100222
ppow_succ' in nasty nat form
pechersky Jun 23, 2026
ec8eff0
mul opposite ppow
pechersky Jun 23, 2026
2bef2f1
MulHom.map_ppow
pechersky Jun 23, 2026
61c87a9
coe_ppow
pechersky Jun 23, 2026
1c0237b
star and self adjoint
pechersky Jun 23, 2026
15b3a9a
ringcon
pechersky Jun 23, 2026
51ba3e1
IsScalarTower
pechersky Jun 24, 2026
8a3146a
ppow_induction
pechersky Jun 24, 2026
936021e
autoparam for easier rws
pechersky Jun 24, 2026
215fe31
distribsmul and smulcomm instances, fixes linearmap
pechersky Jun 24, 2026
a53868e
causeq completion
pechersky Jun 24, 2026
3dce822
explain diamond
pechersky Jun 24, 2026
5300a31
ring transfer
pechersky Jun 24, 2026
5eba48a
hack diamond for nonunital center with instance prio
pechersky Jun 24, 2026
6b1d395
FunLike with more IsPowApply
pechersky Jun 24, 2026
16664f6
Ixx instances
pechersky Jun 24, 2026
5a7ef0c
transferinstance
pechersky Jun 24, 2026
03a7785
formatting
pechersky Jun 24, 2026
9d371f8
subfield
pechersky Jun 24, 2026
61b5b56
ppowRec on the right, matches core npowRec, and match axiom arg order
pechersky Jun 24, 2026
c324489
twosided ideal
pechersky Jun 24, 2026
426ed23
Submodule
pechersky Jun 24, 2026
b936314
GMonoid
pechersky Jun 25, 2026
8686c4f
Bitvec
pechersky Jun 25, 2026
c66b6a6
Filter/Gem
pechersky Jun 25, 2026
3386b99
fix arg order
pechersky Jun 25, 2026
2abd6d9
finsupp pointwise
pechersky Jun 25, 2026
e2f186b
fix additive renaming
pechersky Jun 25, 2026
945f888
PositiveLinearMap
pechersky Jun 25, 2026
0b08c6b
funlike ring
pechersky Jun 25, 2026
8917290
field transfer instance
pechersky Jun 25, 2026
9adad85
UpperLower
pechersky Jun 25, 2026
42efe1e
UInt
pechersky Jun 25, 2026
2a226d5
fix prod diamond
pechersky Jun 25, 2026
5534581
order interval algebra
pechersky Jun 25, 2026
463f31d
CentroidHom
pechersky Jun 25, 2026
b277caa
ppow_mem for MulMemClass
pechersky Jun 25, 2026
8f61589
restricted products
pechersky Jun 25, 2026
a5a1db6
HahnSeries
pechersky Jun 25, 2026
87c605f
fix Function.End diamond, unloack AddConstMap
pechersky Jun 25, 2026
15016a8
solve Pi diamond by different reducibility on PNat
pechersky Jun 26, 2026
058a5e2
SMulZeroClass with PNat
pechersky Jun 26, 2026
ea8be61
IncidenceAlgebra
pechersky Jun 26, 2026
612014a
NNReal
pechersky Jun 26, 2026
68111df
Lie
pechersky Jun 26, 2026
1fceae8
move map_ppow
pechersky Jun 26, 2026
6dd5f5c
DirectSum ring instance
pechersky Jun 26, 2026
07703de
semimodule cat
pechersky Jun 26, 2026
849ff7f
Polynomial
pechersky Jun 26, 2026
6fdc580
LocallyFinsupp
pechersky Jun 26, 2026
f1ad31a
AffineMap
pechersky Jun 26, 2026
592e042
Preadditive
pechersky Jun 26, 2026
6e2b13e
skewalgebra
pechersky Jun 26, 2026
6a02a8e
locallyconstant rings
pechersky Jun 26, 2026
2a1442f
Limits, work around non-linear smul
pechersky Jun 26, 2026
5059a7a
better preadditive fix, unlocks homology
pechersky Jun 26, 2026
ba3ec32
convolutoin bialg
pechersky Jun 26, 2026
94fd656
fix Perm instance which fixes diamond for AddConstEquiv
pechersky Jun 26, 2026
78d8b36
avoid diamond
pechersky Jun 26, 2026
b0d5f86
ModuleCat
pechersky Jun 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ public import Mathlib.Algebra.Group.Nat.Units
public import Mathlib.Algebra.Group.NatPowAssoc
public import Mathlib.Algebra.Group.Opposite
public import Mathlib.Algebra.Group.PNatPowAssoc
public import Mathlib.Algebra.Group.PPow.Basic
public import Mathlib.Algebra.Group.PPow.Defs
public import Mathlib.Algebra.Group.PUnit
public import Mathlib.Algebra.Group.Pi.Basic
public import Mathlib.Algebra.Group.Pi.Lemmas
Expand Down
8 changes: 7 additions & 1 deletion Mathlib/Algebra/AddConstMap/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,15 @@ instance {K : Type*} [AddMonoid K] [AddAction K H] [VAddAssocClass K H H] :
instance : Mul (G →+c[a, a] G) := ⟨comp⟩
instance : One (G →+c[a, a] G) := ⟨.id⟩

instance : Pow (G →+c[a, a] G) ℕ+ where
pow f n := ⟨f^[n], Commute.iterate_left (AddConstMapClass.semiconj f) _⟩

instance : Pow (G →+c[a, a] G) ℕ where
pow f n := ⟨f^[n], Commute.iterate_left (AddConstMapClass.semiconj f) _⟩

instance : Monoid (G →+c[a, a] G) :=
DFunLike.coe_injective.monoid (M₂ := Function.End G) _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl
DFunLike.coe_injective.monoid (M₂ := Function.End G) _ rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
fun _ _ ↦ rfl

theorem mul_def (f g : G →+c[a, a] G) : f * g = f.comp g := rfl
@[simp, push_cast] theorem coe_mul (f g : G →+c[a, a] G) : ⇑(f * g) = f ∘ g := rfl
Expand All @@ -401,6 +405,8 @@ theorem one_def : (1 : G →+c[a, a] G) = .id := rfl

@[simp, push_cast] theorem coe_pow (f : G →+c[a, a] G) (n : ℕ) : ⇑(f ^ n) = f^[n] := rfl

theorem ppow_apply (f : G →+c[a, a] G) (n : ℕ+) (x : G) : (f ^ n) x = f^[n] x := rfl

theorem pow_apply (f : G →+c[a, a] G) (n : ℕ) (x : G) : (f ^ n) x = f^[n] x := rfl

/-- Coercion to functions as a monoid homomorphism to `Function.End G`. -/
Expand Down
5 changes: 4 additions & 1 deletion Mathlib/Algebra/AddConstMap/Equiv.lean
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ instance instMul : Mul (G ≃+c[a, a] G) := ⟨fun f g ↦ g.trans f⟩
instance instInv : Inv (G ≃+c[a, a] G) := ⟨.symm⟩
instance instDiv : Div (G ≃+c[a, a] G) := ⟨fun f g ↦ f * g⁻¹⟩

instance instPowPNat : Pow (G ≃+c[a, a] G) ℕ+ where
pow e n := ⟨e^n, (e.toAddConstMap^n).map_add_const'⟩

instance instPowNat : Pow (G ≃+c[a, a] G) ℕ where
pow e n := ⟨e^n, (e.toAddConstMap^n).map_add_const'⟩

Expand All @@ -127,7 +130,7 @@ instance instPowInt : Pow (G ≃+c[a, a] G) ℤ where

instance instGroup : Group (G ≃+c[a, a] G) :=
toEquiv_injective.group _ rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
fun _ _ ↦ rfl
(fun _ _ ↦ rfl) fun _ _ ↦ rfl

/-- Projection from `G ≃+c[a, a] G` to permutations `G ≃ G`, as a monoid homomorphism. -/
@[simps! apply]
Expand Down
17 changes: 13 additions & 4 deletions Mathlib/Algebra/Algebra/NonUnitalSubalgebra.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1094,8 +1094,10 @@ theorem coe_center : (center R A : Set A) = Set.center A :=
rfl

/-- The center of a non-unital algebra is commutative and associative -/
instance center.instNonUnitalCommSemiring : NonUnitalCommSemiring (center R A) :=
inferInstanceAs <| NonUnitalCommSemiring (NonUnitalSubsemiring.center A)
instance (priority := 75) center.instNonUnitalCommSemiring :
NonUnitalCommSemiring (center R A) where
mul_assoc := Subsemigroup.center.commSemigroup.mul_assoc
mul_comm := Subsemigroup.center.commSemigroup.mul_comm

instance center.instNonUnitalCommRing {A : Type*} [NonUnitalNonAssocRing A] [Module R A]
[IsScalarTower R A A] [SMulCommClass R A A] : NonUnitalCommRing (center R A) :=
Expand All @@ -1121,8 +1123,15 @@ end NonUnitalNonAssocSemiring
variable (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] [IsScalarTower R A A]
[SMulCommClass R A A]

-- no instance diamond, as the `npow` field isn't present in the non-unital case.
example : center.instNonUnitalCommSemiring.toNonUnitalSemiring =
/-- When the ambient algebra is associative, use the inherited subsemiring structure so that
positive powers agree definitionally with the ambient powers. -/
instance center.instNonUnitalCommSemiringOfNonUnitalSemiring :
NonUnitalCommSemiring (center R A) where
__ := NonUnitalSubsemiringClass.toNonUnitalSemiring (center R A)
mul_comm := Subsemigroup.center.commSemigroup.mul_comm

-- no instance diamond
example : (inferInstance : NonUnitalCommSemiring (center R A)).toNonUnitalSemiring =
NonUnitalSubsemiringClass.toNonUnitalSemiring (center R A) := by
with_reducible_and_instances rfl

Expand Down
19 changes: 19 additions & 0 deletions Mathlib/Algebra/Algebra/Operations.lean
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,28 @@ theorem iSup_mul (s : ι → Submodule R A) (t : Submodule R A) : (⨆ i, s i) *
theorem mul_iSup (t : Submodule R A) (s : ι → Submodule R A) : (t * ⨆ i, s i) = ⨆ i, t * s i :=
smul_iSup

instance : Pow (Submodule R A) ℕ+ where
pow s n := ppowRec n n.prop s -- as opposed to `s.toAddSubmonoid ^ n`

@[simp]
protected theorem ppow_zero : M ^ (1 : ℕ+) = M := rfl

protected theorem ppow_succ {n : ℕ+} : M ^ (n + 1) = M ^ n * M := by
rcases n with ⟨_|n, hn⟩
· contradiction
· rfl

private protected theorem ppow_mk_add_two (n : ℕ) :
M ^ (PNat.mk (n + 2) (Nat.succ_pos _)) = M ^ (PNat.mk (n + 1) (Nat.succ_pos _)) * M :=
rfl

/-- Sub-`R`-modules of an `R`-module form an idempotent semiring. -/
instance : NonUnitalSemiring (Submodule R A) where
__ := toAddSubmonoid_injective.semigroup _ mul_toAddSubmonoid
(fun x n => by
induction n using Semigroup.ppow_induction x.toAddSubmonoid with
| h1 => simp
| hsucc n IH => rw [Submodule.ppow_mk_add_two, mul_toAddSubmonoid, IH])
zero_mul := bot_mul
mul_zero := mul_bot
left_distrib := mul_sup
Expand Down
6 changes: 6 additions & 0 deletions Mathlib/Algebra/Category/Grp/Preadditive.lean
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ instance : Zero (M ⟶ N) where

@[simp] lemma hom_zero : (0 : M ⟶ N).hom = 0 := rfl

instance : SMul ℕ+ (M ⟶ N) where
smul n f := ofHom (n • f.hom)

@[simp] lemma hom_psmul (n : ℕ+) (f : M ⟶ N) : (n • f).hom = n • f.hom := rfl

instance : SMul ℕ (M ⟶ N) where
smul n f := ofHom (n • f.hom)

Expand All @@ -59,6 +64,7 @@ instance : SMul ℤ (M ⟶ N) where
instance (P Q : AddCommGrpCat) : AddCommGroup (P ⟶ Q) :=
Function.Injective.addCommGroup (Hom.hom) ConcreteCategory.hom_injective
rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl)

instance : Preadditive AddCommGrpCat where

Expand Down
8 changes: 8 additions & 0 deletions Mathlib/Algebra/Category/ModuleCat/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ instance : Zero (M ⟶ N) where

@[simp] lemma hom_zero : (0 : M ⟶ N).hom = 0 := rfl

set_option backward.privateInPublic true in
set_option backward.privateInPublic.warn false in
instance : SMul ℕ+ (M ⟶ N) where
smul n f := ⟨n • f.hom⟩

@[simp] lemma hom_psmul (n : ℕ+) (f : M ⟶ N) : (n • f).hom = n • f.hom := rfl

set_option backward.privateInPublic true in
set_option backward.privateInPublic.warn false in
instance : SMul ℕ (M ⟶ N) where
Expand Down Expand Up @@ -357,6 +364,7 @@ instance : SMul ℤ (M ⟶ N) where
instance : AddCommGroup (M ⟶ N) :=
Function.Injective.addCommGroup (Hom.hom) hom_injective
rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl)

@[simp] lemma hom_sum {ι : Type*} (f : ι → (M ⟶ N)) (s : Finset ι) :
(∑ i ∈ s, f i).hom = ∑ i ∈ s, (f i).hom :=
Expand Down
6 changes: 6 additions & 0 deletions Mathlib/Algebra/Category/ModuleCat/Semi.lean
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ instance : Zero (M ⟶ N) where

@[simp] lemma hom_zero : (0 : M ⟶ N).hom = 0 := rfl

instance : SMul ℕ+ (M ⟶ N) where
smul n f := ⟨n • f.hom⟩

@[simp] lemma hom_psmul (n : ℕ+) (f : M ⟶ N) : (n • f).hom = n • f.hom := rfl

instance : SMul ℕ (M ⟶ N) where
smul n f := ⟨n • f.hom⟩

Expand All @@ -306,6 +311,7 @@ alias hom_zsmul := hom_nsmul

instance : AddCommMonoid (M ⟶ N) :=
Function.Injective.addCommMonoid Hom.hom hom_injective rfl (fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl)

@[simp] lemma hom_sum {ι : Type*} (f : ι → (M ⟶ N)) (s : Finset ι) :
(∑ i ∈ s, f i).hom = ∑ i ∈ s, (f i).hom :=
Expand Down
26 changes: 17 additions & 9 deletions Mathlib/Algebra/DirectSum/Ring.lean
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ of a `GNonUnitalNonAssocSemiring`. -/
scoped instance (priority := 900) :
NonUnitalNonAssocSemiring (A 0) :=
Function.Injective.nonUnitalNonAssocSemiring (of A 0) DFinsupp.single_injective (of A 0).map_zero
(of A 0).map_add (of_zero_mul A) (map_nsmul _)
(of A 0).map_add (of_zero_mul A) (map_psmul _) (map_nsmul _)

/-- The `SMulWithZero` structure on the grade zero part
of a `GNonUnitalNonAssocSemiring`. -/
Expand All @@ -414,6 +414,10 @@ section Semiring
variable [∀ i, AddCommMonoid (A i)] [AddMonoid ι] [GSemiring A]

@[simp]
theorem of_zero_ppow (a : A 0) (n : ℕ+) :
of A 0 (a ^ n) = of A 0 a ^ n := by
induction n using Semigroup.ppow_induction a <;> simp [*, ppow_mk_add_one]

theorem of_zero_pow (a : A 0) : ∀ n : ℕ, of A 0 (a ^ n) = of A 0 a ^ n
| 0 => by rw [pow_zero, pow_zero, DirectSum.of_zero_one]
-- Porting note: Lean doesn't think this terminates if we only use `of_zero_pow` alone
Expand All @@ -437,7 +441,8 @@ theorem of_zero_ofNat (n : ℕ) [n.AtLeastTwo] : of A 0 ofNat(n) = ofNat(n) :=
/-- The `Semiring` structure derived from `GSemiring A`. -/
scoped instance (priority := 900) : Semiring (A 0) :=
Function.Injective.semiring (of A 0) DFinsupp.single_injective (of A 0).map_zero (of_zero_one A)
(of A 0).map_add (of_zero_mul A) (fun _ _ ↦ (of A 0).map_nsmul _ _)
(of A 0).map_add (of_zero_mul A) (fun _ _ ↦ (of A 0).map_psmul _ _)
(fun _ _ ↦ (of A 0).map_nsmul _ _) (fun _ _ => of_zero_ppow _ _ _)
(fun _ _ => of_zero_pow _ _ _) (of_natCast A)

/-- `of A 0` is a `RingHom`, using the `DirectSum.GradeZero.semiring` structure. -/
Expand All @@ -462,7 +467,8 @@ variable [∀ i, AddCommMonoid (A i)] [AddCommMonoid ι] [GCommSemiring A]
/-- The `CommSemiring` structure derived from `GCommSemiring A`. -/
scoped instance (priority := 900) : CommSemiring (A 0) :=
Function.Injective.commSemiring (of A 0) DFinsupp.single_injective (of A 0).map_zero
(of_zero_one A) (of A 0).map_add (of_zero_mul A) (fun _ _ ↦ map_nsmul _ _ _)
(of_zero_one A) (of A 0).map_add (of_zero_mul A) (fun _ _ ↦ map_psmul _ _ _)
(fun _ _ ↦ map_nsmul _ _ _) (fun _ _ => of_zero_ppow _ _ _)
(fun _ _ => of_zero_pow _ _ _) (of_natCast A)

end CommSemiring
Expand All @@ -474,8 +480,8 @@ variable [∀ i, AddCommGroup (A i)] [AddZeroClass ι] [GNonUnitalNonAssocSemiri
/-- The `NonUnitalNonAssocRing` derived from `GNonUnitalNonAssocSemiring A`. -/
scoped instance (priority := 900) : NonUnitalNonAssocRing (A 0) :=
Function.Injective.nonUnitalNonAssocRing (of A 0) DFinsupp.single_injective (of A 0).map_zero
(of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub (fun _ _ ↦ map_nsmul _ _ _)
(fun _ _ ↦ map_zsmul _ _ _)
(of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub (fun _ _ ↦ map_psmul _ _ _)
(fun _ _ ↦ map_nsmul _ _ _) (fun _ _ ↦ map_zsmul _ _ _)

end Ring

Expand All @@ -494,8 +500,9 @@ theorem of_intCast (n : ℤ) : of A 0 n = n := by
/-- The `Ring` derived from `GSemiring A`. -/
scoped instance (priority := 900) : Ring (A 0) :=
Function.Injective.ring (of A 0) DFinsupp.single_injective (of A 0).map_zero (of_zero_one A)
(of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub (fun _ _ ↦ map_nsmul _ _ _)
(fun _ _ ↦ map_zsmul _ _ _) (fun _ _ => of_zero_pow _ _ _) (of_natCast A) (of_intCast A)
(of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub (fun _ _ ↦ map_psmul _ _ _)
(fun _ _ ↦ map_nsmul _ _ _) (fun _ _ ↦ map_zsmul _ _ _) (fun _ _ => of_zero_ppow _ _ _)
(fun _ _ => of_zero_pow _ _ _) (of_natCast A) (of_intCast A)

end Ring

Expand All @@ -506,8 +513,9 @@ variable [∀ i, AddCommGroup (A i)] [AddCommMonoid ι] [GCommRing A]
/-- The `CommRing` derived from `GCommSemiring A`. -/
scoped instance (priority := 900) : CommRing (A 0) :=
Function.Injective.commRing (of A 0) DFinsupp.single_injective (of A 0).map_zero (of_zero_one A)
(of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub (fun _ _ ↦ map_nsmul _ _ _)
(fun _ _ ↦ map_zsmul _ _ _) (fun _ _ => of_zero_pow _ _ _) (of_natCast A) (of_intCast A)
(of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub (fun _ _ ↦ map_psmul _ _ _)
(fun _ _ ↦ map_nsmul _ _ _) (fun _ _ ↦ map_zsmul _ _ _) (fun _ _ => of_zero_ppow _ _ _)
(fun _ _ => of_zero_pow _ _ _) (of_natCast A) (of_intCast A)

end CommRing

Expand Down
42 changes: 24 additions & 18 deletions Mathlib/Algebra/Field/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,21 @@ noncomputable abbrev Field.ofIsUnitOrEqZero [CommRing R] (h : ∀ a : R, IsUnit
end NoncomputableDefs

namespace Function.Injective
variable [Zero K] [Add K] [Neg K] [Sub K] [One K] [Mul K] [Inv K] [Div K] [SMul ℕ K] [SMul K]
[SMul ℚ≥0 K] [SMul ℚ K] [Pow K ℕ] [Pow K ] [NatCast K] [IntCast K] [NNRatCast K] [RatCast K]
(f : K → L) (hf : Injective f)
variable [Zero K] [Add K] [Neg K] [Sub K] [One K] [Mul K] [Inv K] [Div K] [SMul ℕ+ K] [SMul K]
[SMul ℤ K] [SMul ℚ≥0 K] [SMul ℚ K] [Pow K ℕ+] [Pow K ] [Pow K ℤ] [NatCast K] [IntCast K]
[NNRatCast K] [RatCast K] (f : K → L) (hf : Injective f)

/-- Pullback a `DivisionSemiring` along an injective function. -/
-- See note [reducible non-instances]
protected abbrev divisionSemiring [DivisionSemiring L] (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y)
(inv : ∀ x, f x⁻¹ = (f x)⁻¹) (div : ∀ x y, f (x / y) = f x / f y)
(nsmul : ∀ (n : ℕ) (x), f (n • x) = n • f x) (nnqsmul : ∀ (q : ℚ≥0) (x), f (q • x) = q • f x)
(psmul : ∀ (n : ℕ+) (x), f (n • x) = n • f x) (nsmul : ∀ (n : ℕ) (x), f (n • x) = n • f x)
(nnqsmul : ∀ (q : ℚ≥0) (x), f (q • x) = q • f x) (ppow : ∀ (x) (n : ℕ+), f (x ^ n) = f x ^ n)
(npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n) (zpow : ∀ (x) (n : ℤ), f (x ^ n) = f x ^ n)
(natCast : ∀ n : ℕ, f n = n) (nnratCast : ∀ q : ℚ≥0, f q = q) : DivisionSemiring K where
toSemiring := hf.semiring f zero one add mul nsmul npow natCast
__ := hf.groupWithZero f zero one mul inv div npow zpow
toSemiring := hf.semiring f zero one add mul psmul nsmul ppow npow natCast
__ := hf.groupWithZero f zero one mul inv div ppow npow zpow
nnratCast_def q := hf <| by rw [nnratCast, NNRat.cast_def, div, natCast, natCast]
nnqsmul := (· • ·)
nnqsmul_def q a := hf <| by rw [nnqsmul, NNRat.smul_def, mul, nnratCast]
Expand All @@ -247,15 +248,17 @@ protected abbrev divisionSemiring [DivisionSemiring L] (zero : f 0 = 0) (one : f
protected abbrev divisionRing [DivisionRing L] (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y)
(neg : ∀ x, f (-x) = -f x) (sub : ∀ x y, f (x - y) = f x - f y) (inv : ∀ x, f x⁻¹ = (f x)⁻¹)
(div : ∀ x y, f (x / y) = f x / f y)
(div : ∀ x y, f (x / y) = f x / f y) (psmul : ∀ (n : ℕ+) (x), f (n • x) = n • f x)
(nsmul : ∀ (n : ℕ) (x), f (n • x) = n • f x) (zsmul : ∀ (n : ℤ) (x), f (n • x) = n • f x)
(nnqsmul : ∀ (q : ℚ≥0) (x), f (q • x) = q • f x) (qsmul : ∀ (q : ℚ) (x), f (q • x) = q • f x)
(ppow : ∀ (x) (n : ℕ+), f (x ^ n) = f x ^ n)
(npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n) (zpow : ∀ (x) (n : ℤ), f (x ^ n) = f x ^ n)
(natCast : ∀ n : ℕ, f n = n) (intCast : ∀ n : ℤ, f n = n) (nnratCast : ∀ q : ℚ≥0, f q = q)
(ratCast : ∀ q : ℚ, f q = q) : DivisionRing K where
toRing := hf.ring f zero one add mul neg sub nsmul zsmul npow natCast intCast
__ := hf.groupWithZero f zero one mul inv div npow zpow
__ := hf.divisionSemiring f zero one add mul inv div nsmul nnqsmul npow zpow natCast nnratCast
toRing := hf.ring f zero one add mul neg sub psmul nsmul zsmul ppow npow natCast intCast
__ := hf.groupWithZero f zero one mul inv div ppow npow zpow
__ := hf.divisionSemiring f zero one add mul inv div psmul nsmul nnqsmul ppow npow zpow natCast
nnratCast
ratCast_def q := hf <| by rw [ratCast, div, intCast, natCast, Rat.cast_def]
qsmul := (· • ·)
qsmul_def q a := hf <| by rw [qsmul, mul, Rat.smul_def, ratCast]
Expand All @@ -265,28 +268,31 @@ protected abbrev divisionRing [DivisionRing L] (zero : f 0 = 0) (one : f 1 = 1)
protected abbrev semifield [Semifield L] (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y)
(inv : ∀ x, f x⁻¹ = (f x)⁻¹) (div : ∀ x y, f (x / y) = f x / f y)
(nsmul : ∀ (n : ℕ) (x), f (n • x) = n • f x) (nnqsmul : ∀ (q : ℚ≥0) (x), f (q • x) = q • f x)
(psmul : ∀ (n : ℕ+) (x), f (n • x) = n • f x) (nsmul : ∀ (n : ℕ) (x), f (n • x) = n • f x)
(nnqsmul : ∀ (q : ℚ≥0) (x), f (q • x) = q • f x) (ppow : ∀ (x) (n : ℕ+), f (x ^ n) = f x ^ n)
(npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n) (zpow : ∀ (x) (n : ℤ), f (x ^ n) = f x ^ n)
(natCast : ∀ n : ℕ, f n = n) (nnratCast : ∀ q : ℚ≥0, f q = q) : Semifield K where
toCommSemiring := hf.commSemiring f zero one add mul nsmul npow natCast
__ := hf.commGroupWithZero f zero one mul inv div npow zpow
__ := hf.divisionSemiring f zero one add mul inv div nsmul nnqsmul npow zpow natCast nnratCast
toCommSemiring := hf.commSemiring f zero one add mul psmul nsmul ppow npow natCast
__ := hf.commGroupWithZero f zero one mul inv div ppow npow zpow
__ := hf.divisionSemiring f zero one add mul inv div psmul nsmul nnqsmul ppow npow zpow natCast
nnratCast

/-- Pullback a `Field` along an injective function. -/
-- See note [reducible non-instances]
protected abbrev field [Field L] (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y)
(neg : ∀ x, f (-x) = -f x) (sub : ∀ x y, f (x - y) = f x - f y) (inv : ∀ x, f x⁻¹ = (f x)⁻¹)
(div : ∀ x y, f (x / y) = f x / f y)
(div : ∀ x y, f (x / y) = f x / f y) (psmul : ∀ (n : ℕ+) (x), f (n • x) = n • f x)
(nsmul : ∀ (n : ℕ) (x), f (n • x) = n • f x) (zsmul : ∀ (n : ℤ) (x), f (n • x) = n • f x)
(nnqsmul : ∀ (q : ℚ≥0) (x), f (q • x) = q • f x) (qsmul : ∀ (q : ℚ) (x), f (q • x) = q • f x)
(ppow : ∀ (x) (n : ℕ+), f (x ^ n) = f x ^ n)
(npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n) (zpow : ∀ (x) (n : ℤ), f (x ^ n) = f x ^ n)
(natCast : ∀ n : ℕ, f n = n) (intCast : ∀ n : ℤ, f n = n) (nnratCast : ∀ q : ℚ≥0, f q = q)
(ratCast : ∀ q : ℚ, f q = q) :
Field K where
toCommRing := hf.commRing f zero one add mul neg sub nsmul zsmul npow natCast intCast
__ := hf.divisionRing f zero one add mul neg sub inv div nsmul zsmul nnqsmul qsmul npow zpow
natCast intCast nnratCast ratCast
toCommRing := hf.commRing f zero one add mul neg sub psmul nsmul zsmul ppow npow natCast intCast
__ := hf.divisionRing f zero one add mul neg sub inv div psmul nsmul zsmul nnqsmul qsmul ppow npow
zpow natCast intCast nnratCast ratCast

end Function.Injective

Expand Down
8 changes: 4 additions & 4 deletions Mathlib/Algebra/Field/Subfield/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ instance (priority := 75) toDivisionRing (s : S) : DivisionRing s := fast_instan
Subtype.coe_injective.divisionRing ((↑) : s → K)
rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl)
(fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
(fun _ _ ↦ rfl) (coe_nnqsmul _) (coe_qsmul _) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
(fun _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl)
(fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (coe_nnqsmul _) (coe_qsmul _) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
(fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl)

-- Prefer subclasses of `Field` over subclasses of `SubfieldClass`.
/-- A subfield of a field inherits a field structure -/
Expand All @@ -120,8 +120,8 @@ instance (priority := 75) toField {K} [Field K] [SetLike S K] [SubfieldClass S K
Subtype.coe_injective.field ((↑) : s → K)
rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl)
(fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
(coe_nnqsmul _) (coe_qsmul _) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl)
(fun _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl)
(fun _ _ ↦ rfl) (coe_nnqsmul _) (coe_qsmul _) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
(fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl)

end SubfieldClass

Expand Down
Loading
Loading