/-
Copyright 2026 The Formal Conjectures Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-/modulepublicimportMathlib.Algebra.Squarefree.Basic@[expose]publicsectionvariable{MM₀:Type*}{rm:M}{k:ℕ}sectionMonoidvariable[MonoidM]defPowerfree(k:ℕ)(m:M):Prop:=∀⦃x:M⦄,x^k∣m→IsUnitxtheoremPowerfree.of_le{ab:ℕ}(hab:a≤b)(hm:Powerfreeam):Powerfreebm:=funxhx=>hm(dvd_of_mul_right_dvd(pow_mul_pow_subxhab▸hx))theoremPowerfree.of_dvd(hrm:r∣m)(hm:Powerfreekm):Powerfreekr:=fun_hx=>hm(hx.transhrm)theorempowerfree_congr(hrm:Associatedrm):Powerfreekr↔Powerfreekm:=⟨funh=>h.of_dvdhrm.dvd',funh=>h.of_dvdhrm.dvd⟩@[simp]theorempowerfree_neg[HasDistribNegM]:Powerfreek(-m)↔Powerfreekm:=powerfree_congr(Associated.reflm).neg_left@[simp]theorempowerfree_two{m:M}:Powerfree2m↔Squarefreemwheremphxhx:=h(sqx▸hx)mprhxhx:=hx(sqx▸hx)endMonoidsectionCommMonoidvariable[CommMonoidM]theoremIsUnit.powerfree(h:IsUnitm)(hk:k≠0):Powerfreekm:=fun_hx=>(isUnit_pow_iffhk).1(isUnit_of_dvd_unithxh)@[simp]theorempowerfree_one(hk:k≠0):Powerfreek(1:M):=isUnit_one.powerfreehksuccM:Type u_1m:Mk:ℕinst✝:CommMonoidMh:Irreduciblemy:Mz:Mn:ℕih:2≤n→m=y^n*z→IsUnityhk:2≤n+1hz:m=y^n*(y*z)⊢ IsUnityrcasesh.isUnit_or_isUnithzwith(hu|hu)succ.inlM:Type u_1m:Mk:ℕinst✝:CommMonoidMh:Irreduciblemy:Mz:Mn:ℕih:2≤n→m=y^n*z→IsUnityhk:2≤n+1hz:m=y^n*(y*z)hu:IsUnit(y^n)⊢ IsUnitysucc.inrM:Type u_1m:Mk:ℕinst✝:CommMonoidMh:Irreduciblemy:Mz:Mn:ℕih:2≤n→m=y^n*z→IsUnityhk:2≤n+1hz:m=y^n*(y*z)hu:IsUnit(y*z)⊢ IsUnity·succ.inlM:Type u_1m:Mk:ℕinst✝:CommMonoidMh:Irreduciblemy:Mz:Mn:ℕih:2≤n→m=y^n*z→IsUnityhk:2≤n+1hz:m=y^n*(y*z)hu:IsUnit(y^n)⊢ IsUnityexact(isUnit_pow_iff(byM:Type u_1m:Mk:ℕinst✝:CommMonoidMh:Irreduciblemy:Mz:Mn:ℕih:2≤n→m=y^n*z→IsUnityhk:2≤n+1hz:m=y^n*(y*z)hu:IsUnit(y^n)⊢ n≠0linarithAll goals completed! 🐙)).1hu·succ.inrM:Type u_1m:Mk:ℕinst✝:CommMonoidMh:Irreduciblemy:Mz:Mn:ℕih:2≤n→m=y^n*z→IsUnityhk:2≤n+1hz:m=y^n*(y*z)hu:IsUnit(y*z)⊢ IsUnityapplyisUnit_of_mul_isUnit_lefthuAll goals completed! 🐙endCommMonoid@[simp]theoremnot_powerfree_zero[MonoidWithZeroM₀][NontrivialM₀](k:ℕ):¬Powerfreek(0:M₀):=byM₀:Type u_2inst✝¹:MonoidWithZeroM₀inst✝:NontrivialM₀k:ℕ⊢ ¬Powerfreek0rw[Powerfree,M₀:Type u_2inst✝¹:MonoidWithZeroM₀inst✝:NontrivialM₀k:ℕ⊢ ¬∀⦃x:M₀⦄,x^k∣0→IsUnitxM₀:Type u_2inst✝¹:MonoidWithZeroM₀inst✝:NontrivialM₀k:ℕ⊢ ∃x,¬(x^k∣0→IsUnitx)not_forallM₀:Type u_2inst✝¹:MonoidWithZeroM₀inst✝:NontrivialM₀k:ℕ⊢ ∃x,¬(x^k∣0→IsUnitx)M₀:Type u_2inst✝¹:MonoidWithZeroM₀inst✝:NontrivialM₀k:ℕ⊢ ∃x,¬(x^k∣0→IsUnitx)]M₀:Type u_2inst✝¹:MonoidWithZeroM₀inst✝:NontrivialM₀k:ℕ⊢ ∃x,¬(x^k∣0→IsUnitx)exact⟨0,byM₀:Type u_2inst✝¹:MonoidWithZeroM₀inst✝:NontrivialM₀k:ℕ⊢ ¬(0^k∣0→IsUnit0)simpAll goals completed! 🐙⟩theoremPrime.powerfree[CommMonoidWithZeroM₀][IsCancelMulZeroM₀]{m:M₀}(h:Primem)(hk:2≤k):Powerfreekm:=h.irreducible.powerfreehk