/-
Copyright (c) 2022 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa

! This file was ported from Lean 3 source module algebra.monoid_algebra.degree
! leanprover-community/mathlib commit 932872382355f00112641d305ba0619305dc8642
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.Algebra.MonoidAlgebra.Support

/-!
# Lemmas about the `sup` and `inf` of the support of `add_monoid_algebra`

> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.

## TODO
The current plan is to state and prove lemmas about `finset.sup (finsupp.support f) D` with a
"generic" degree/weight function `D` from the grading Type `A` to a somewhat ordered Type `B`.

Next, the general lemmas get specialized for some yet-to-be-defined `degree`s.
-/

variable {R A T B ι : Type _}

namespace AddMonoidAlgebra

open Classical BigOperators

/-! ### Results about the `finset.sup` and `finset.inf` of `finsupp.support` -/

section GeneralResultsAssumingSemilatticeSup

variable [SemilatticeSup B] [OrderBot B] [SemilatticeInf T] [OrderTop T]

section Semiring

variable [Semiring R]

section ExplicitDegrees

/-!

In this section, we use `degb` and `degt` to denote "degree functions" on `A` with values in
a type with *b*ot or *t*op respectively.
-/

variable (degb : A → B) (degt : A → T) (f g : AddMonoidAlgebra R A)

/- warning: add_monoid_algebra.sup_support_add_le -> AddMonoidAlgebra.sup_support_add_le is a dubious translation:
lean 3 declaration is
  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : SemilatticeSup.{u3} B] [_inst_2 : OrderBot.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1)))] [_inst_5 : Semiring.{u1} R] (degb : A -> B) (f : AddMonoidAlgebra.{u1, u2} R A _inst_5) (g : AddMonoidAlgebra.{u1, u2} R A _inst_5), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_5)))) (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.{u1, u2} R A _inst_5) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddZeroClass.toHasAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoid.toAddZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddCommMonoid.toAddMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.addCommMonoid.{u2, u1} R A _inst_5))))) f g)) degb) (Sup.sup.{u3} B (SemilatticeSup.toHasSup.{u3} B _inst_1) (Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_5)))) f) degb) (Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_5)))) g) degb))
but is expected to have type
  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : SemilatticeSup.{u3} B] [_inst_2 : OrderBot.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1)))] [_inst_5 : Semiring.{u1} R] (degb : A -> B) (f : AddMonoidAlgebra.{u1, u2} R A _inst_5) (g : AddMonoidAlgebra.{u1, u2} R A _inst_5), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_5)) (HAdd.hAdd.{max u1 u2, max u1 u2, max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.{u1, u2} R A _inst_5) (instHAdd.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddZeroClass.toAdd.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoid.toAddZeroClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddCommMonoid.toAddMonoid.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.addCommMonoid.{u1, u2} R A _inst_5))))) f g)) degb) (Sup.sup.{u3} B (SemilatticeSup.toSup.{u3} B _inst_1) (Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_5)) f) degb) (Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_5)) g) degb))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.sup_support_add_le AddMonoidAlgebra.sup_support_add_leₓ'. -/
theorem sup_support_add_le : (f + g).support.sup degb ≤ f.support.sup degb ⊔ g.support.sup degb :=
  (Finset.sup_mono Finsupp.support_add).trans_eq Finset.sup_union
#align add_monoid_algebra.sup_support_add_le AddMonoidAlgebra.sup_support_add_le

/- warning: add_monoid_algebra.le_inf_support_add -> AddMonoidAlgebra.le_inf_support_add is a dubious translation:
lean 3 declaration is
  forall {R : Type.{u1}} {A : Type.{u2}} {T : Type.{u3}} [_inst_3 : SemilatticeInf.{u3} T] [_inst_4 : OrderTop.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3)))] [_inst_5 : Semiring.{u1} R] (degt : A -> T) (f : AddMonoidAlgebra.{u1, u2} R A _inst_5) (g : AddMonoidAlgebra.{u1, u2} R A _inst_5), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (Inf.inf.{u3} T (SemilatticeInf.toHasInf.{u3} T _inst_3) (Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_5)))) f) degt) (Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_5)))) g) degt)) (Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_5)))) (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.{u1, u2} R A _inst_5) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddZeroClass.toHasAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoid.toAddZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddCommMonoid.toAddMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.addCommMonoid.{u2, u1} R A _inst_5))))) f g)) degt)
but is expected to have type
  forall {R : Type.{u1}} {A : Type.{u2}} {T : Type.{u3}} [_inst_3 : SemilatticeInf.{u3} T] [_inst_4 : OrderTop.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3)))] [_inst_5 : Semiring.{u1} R] (degt : A -> T) (f : AddMonoidAlgebra.{u1, u2} R A _inst_5) (g : AddMonoidAlgebra.{u1, u2} R A _inst_5), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (Inf.inf.{u3} T (SemilatticeInf.toInf.{u3} T _inst_3) (Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_5)) f) degt) (Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_5)) g) degt)) (Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_5)) (HAdd.hAdd.{max u1 u2, max u1 u2, max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.{u1, u2} R A _inst_5) (instHAdd.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddZeroClass.toAdd.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoid.toAddZeroClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddCommMonoid.toAddMonoid.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.addCommMonoid.{u1, u2} R A _inst_5))))) f g)) degt)
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.le_inf_support_add AddMonoidAlgebra.le_inf_support_addₓ'. -/
theorem le_inf_support_add : f.support.inf degt ⊓ g.support.inf degt ≤ (f + g).support.inf degt :=
  sup_support_add_le (fun a : A => OrderDual.toDual (degt a)) f g
#align add_monoid_algebra.le_inf_support_add AddMonoidAlgebra.le_inf_support_add

end ExplicitDegrees

section AddOnly

variable [Add A] [Add B] [Add T] [CovariantClass B B (· + ·) (· ≤ ·)]
  [CovariantClass B B (Function.swap (· + ·)) (· ≤ ·)] [CovariantClass T T (· + ·) (· ≤ ·)]
  [CovariantClass T T (Function.swap (· + ·)) (· ≤ ·)]

#print AddMonoidAlgebra.sup_support_mul_le /-
theorem sup_support_mul_le {degb : A → B} (degbm : ∀ {a b}, degb (a + b) ≤ degb a + degb b)
    (f g : AddMonoidAlgebra R A) :
    (f * g).support.sup degb ≤ f.support.sup degb + g.support.sup degb :=
  by
  refine' (Finset.sup_mono <| support_mul _ _).trans _
  simp_rw [Finset.sup_bunionᵢ, Finset.sup_singleton]
  refine' Finset.sup_le fun fd fds => Finset.sup_le fun gd gds => degbm.trans <| add_le_add _ _ <;>
    exact Finset.le_sup ‹_›
#align add_monoid_algebra.sup_support_mul_le AddMonoidAlgebra.sup_support_mul_le
-/

#print AddMonoidAlgebra.le_inf_support_mul /-
theorem le_inf_support_mul {degt : A → T} (degtm : ∀ {a b}, degt a + degt b ≤ degt (a + b))
    (f g : AddMonoidAlgebra R A) :
    f.support.inf degt + g.support.inf degt ≤ (f * g).support.inf degt :=
  OrderDual.ofDual_le_ofDual.mpr <|
    sup_support_mul_le (fun a b => OrderDual.ofDual_le_ofDual.mp degtm) f g
#align add_monoid_algebra.le_inf_support_mul AddMonoidAlgebra.le_inf_support_mul
-/

end AddOnly

section AddMonoids

variable [AddMonoid A] [AddMonoid B] [CovariantClass B B (· + ·) (· ≤ ·)]
  [CovariantClass B B (Function.swap (· + ·)) (· ≤ ·)] [AddMonoid T]
  [CovariantClass T T (· + ·) (· ≤ ·)] [CovariantClass T T (Function.swap (· + ·)) (· ≤ ·)]
  {degb : A → B} {degt : A → T}

/- warning: add_monoid_algebra.sup_support_list_prod_le -> AddMonoidAlgebra.sup_support_list_prod_le is a dubious translation:
lean 3 declaration is
  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : SemilatticeSup.{u3} B] [_inst_2 : OrderBot.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1)))] [_inst_5 : Semiring.{u1} R] [_inst_6 : AddMonoid.{u2} A] [_inst_7 : AddMonoid.{u3} B] [_inst_8 : CovariantClass.{u3, u3} B B (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toHasAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7)))) (LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))))] [_inst_9 : CovariantClass.{u3, u3} B B (Function.swap.{succ u3, succ u3, succ u3} B B (fun (ᾰ : B) (ᾰ : B) => B) (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toHasAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7))))) (LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))))] {degb : A -> B}, (LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (degb (OfNat.ofNat.{u2} A 0 (OfNat.mk.{u2} A 0 (Zero.zero.{u2} A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6)))))) (OfNat.ofNat.{u3} B 0 (OfNat.mk.{u3} B 0 (Zero.zero.{u3} B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7)))))) -> (forall (a : A) (b : A), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (degb (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toHasAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))) a b)) (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toHasAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7))) (degb a) (degb b))) -> (forall (l : List.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5)), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_5)))) (List.prod.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.hasMul.{u1, u2} R A _inst_5 (AddZeroClass.toHasAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))) (AddMonoidAlgebra.one.{u1, u2} R A _inst_5 (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))) l)) degb) (List.sum.{u3} B (AddZeroClass.toHasAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7)) (List.map.{max u2 u1, u3} (AddMonoidAlgebra.{u1, u2} R A _inst_5) B (fun (f : AddMonoidAlgebra.{u1, u2} R A _inst_5) => Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_5)))) f) degb) l)))
but is expected to have type
  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : SemilatticeSup.{u3} B] [_inst_2 : OrderBot.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1)))] [_inst_5 : Semiring.{u1} R] [_inst_6 : AddMonoid.{u2} A] [_inst_7 : AddMonoid.{u3} B] [_inst_8 : CovariantClass.{u3, u3} B B (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1157 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1159 : B) => HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1157 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1159) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1172 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1174 : B) => LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1172 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1174)] [_inst_9 : CovariantClass.{u3, u3} B B (Function.swap.{succ u3, succ u3, succ u3} B B (fun (ᾰ : B) (ᾰ : B) => B) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1194 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1196 : B) => HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1194 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1196)) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1209 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1211 : B) => LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1209 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1211)] {degb : A -> B}, (LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (degb (OfNat.ofNat.{u2} A 0 (Zero.toOfNat0.{u2} A (AddMonoid.toZero.{u2} A _inst_6)))) (OfNat.ofNat.{u3} B 0 (Zero.toOfNat0.{u3} B (AddMonoid.toZero.{u3} B _inst_7)))) -> (forall (a : A) (b : A), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (degb (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))) a b)) (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7))) (degb a) (degb b))) -> (forall (l : List.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5)), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_5)) (List.prod.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.hasMul.{u1, u2} R A _inst_5 (AddZeroClass.toAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))) (AddMonoidAlgebra.one.{u1, u2} R A _inst_5 (AddMonoid.toZero.{u2} A _inst_6)) l)) degb) (List.sum.{u3} B (AddZeroClass.toAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7)) (AddMonoid.toZero.{u3} B _inst_7) (List.map.{max u1 u2, u3} (AddMonoidAlgebra.{u1, u2} R A _inst_5) B (fun (f : AddMonoidAlgebra.{u1, u2} R A _inst_5) => Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_5)) f) degb) l)))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.sup_support_list_prod_le AddMonoidAlgebra.sup_support_list_prod_leₓ'. -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
theorem sup_support_list_prod_le (degb0 : degb 0 ≤ 0)
    (degbm : ∀ a b, degb (a + b) ≤ degb a + degb b) :
    ∀ l : List (AddMonoidAlgebra R A),
      l.Prod.support.sup degb ≤ (l.map fun f : AddMonoidAlgebra R A => f.support.sup degb).Sum
  | [] => by
    rw [List.map_nil, Finset.sup_le_iff, List.prod_nil, List.sum_nil]
    exact fun a ha => by rwa [finset.mem_singleton.mp (Finsupp.support_single_subset ha)]
  | f::fs => by
    rw [List.prod_cons, List.map_cons, List.sum_cons]
    exact (sup_support_mul_le degbm _ _).trans (add_le_add_left (sup_support_list_prod_le _) _)
#align add_monoid_algebra.sup_support_list_prod_le AddMonoidAlgebra.sup_support_list_prod_le

/- warning: add_monoid_algebra.le_inf_support_list_prod -> AddMonoidAlgebra.le_inf_support_list_prod is a dubious translation:
lean 3 declaration is
  forall {R : Type.{u1}} {A : Type.{u2}} {T : Type.{u3}} [_inst_3 : SemilatticeInf.{u3} T] [_inst_4 : OrderTop.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3)))] [_inst_5 : Semiring.{u1} R] [_inst_6 : AddMonoid.{u2} A] [_inst_10 : AddMonoid.{u3} T] [_inst_11 : CovariantClass.{u3, u3} T T (HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toHasAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10)))) (LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))))] [_inst_12 : CovariantClass.{u3, u3} T T (Function.swap.{succ u3, succ u3, succ u3} T T (fun (ᾰ : T) (ᾰ : T) => T) (HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toHasAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10))))) (LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))))] {degt : A -> T}, (LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (OfNat.ofNat.{u3} T 0 (OfNat.mk.{u3} T 0 (Zero.zero.{u3} T (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10))))) (degt (OfNat.ofNat.{u2} A 0 (OfNat.mk.{u2} A 0 (Zero.zero.{u2} A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))))))) -> (forall (a : A) (b : A), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toHasAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10))) (degt a) (degt b)) (degt (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toHasAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))) a b))) -> (forall (l : List.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5)), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (List.sum.{u3} T (AddZeroClass.toHasAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10)) (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10)) (List.map.{max u2 u1, u3} (AddMonoidAlgebra.{u1, u2} R A _inst_5) T (fun (f : AddMonoidAlgebra.{u1, u2} R A _inst_5) => Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_5)))) f) degt) l)) (Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_5)))) (List.prod.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.hasMul.{u1, u2} R A _inst_5 (AddZeroClass.toHasAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))) (AddMonoidAlgebra.one.{u1, u2} R A _inst_5 (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))) l)) degt))
but is expected to have type
  forall {R : Type.{u1}} {A : Type.{u2}} {T : Type.{u3}} [_inst_3 : SemilatticeInf.{u3} T] [_inst_4 : OrderTop.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3)))] [_inst_5 : Semiring.{u1} R] [_inst_6 : AddMonoid.{u2} A] [_inst_10 : AddMonoid.{u3} T] [_inst_11 : CovariantClass.{u3, u3} T T (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1638 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1640 : T) => HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1638 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1640) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1653 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1655 : T) => LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1653 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1655)] [_inst_12 : CovariantClass.{u3, u3} T T (Function.swap.{succ u3, succ u3, succ u3} T T (fun (ᾰ : T) (ᾰ : T) => T) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1675 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1677 : T) => HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1675 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1677)) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1690 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1692 : T) => LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1690 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1692)] {degt : A -> T}, (LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (OfNat.ofNat.{u3} T 0 (Zero.toOfNat0.{u3} T (AddMonoid.toZero.{u3} T _inst_10))) (degt (OfNat.ofNat.{u2} A 0 (Zero.toOfNat0.{u2} A (AddMonoid.toZero.{u2} A _inst_6))))) -> (forall (a : A) (b : A), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10))) (degt a) (degt b)) (degt (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))) a b))) -> (forall (l : List.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5)), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (List.sum.{u3} T (AddZeroClass.toAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10)) (AddMonoid.toZero.{u3} T _inst_10) (List.map.{max u1 u2, u3} (AddMonoidAlgebra.{u1, u2} R A _inst_5) T (fun (f : AddMonoidAlgebra.{u1, u2} R A _inst_5) => Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_5)) f) degt) l)) (Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_5)) (List.prod.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.hasMul.{u1, u2} R A _inst_5 (AddZeroClass.toAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))) (AddMonoidAlgebra.one.{u1, u2} R A _inst_5 (AddMonoid.toZero.{u2} A _inst_6)) l)) degt))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.le_inf_support_list_prod AddMonoidAlgebra.le_inf_support_list_prodₓ'. -/
theorem le_inf_support_list_prod (degt0 : 0 ≤ degt 0)
    (degtm : ∀ a b, degt a + degt b ≤ degt (a + b)) (l : List (AddMonoidAlgebra R A)) :
    (l.map fun f : AddMonoidAlgebra R A => f.support.inf degt).Sum ≤ l.Prod.support.inf degt :=
  OrderDual.ofDual_le_ofDual.mpr <|
    sup_support_list_prod_le (OrderDual.ofDual_le_ofDual.mp degt0)
      (fun a b => OrderDual.ofDual_le_ofDual.mp (degtm _ _)) l
#align add_monoid_algebra.le_inf_support_list_prod AddMonoidAlgebra.le_inf_support_list_prod

/- warning: add_monoid_algebra.sup_support_pow_le -> AddMonoidAlgebra.sup_support_pow_le is a dubious translation:
lean 3 declaration is
  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : SemilatticeSup.{u3} B] [_inst_2 : OrderBot.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1)))] [_inst_5 : Semiring.{u1} R] [_inst_6 : AddMonoid.{u2} A] [_inst_7 : AddMonoid.{u3} B] [_inst_8 : CovariantClass.{u3, u3} B B (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toHasAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7)))) (LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))))] [_inst_9 : CovariantClass.{u3, u3} B B (Function.swap.{succ u3, succ u3, succ u3} B B (fun (ᾰ : B) (ᾰ : B) => B) (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toHasAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7))))) (LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))))] {degb : A -> B}, (LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (degb (OfNat.ofNat.{u2} A 0 (OfNat.mk.{u2} A 0 (Zero.zero.{u2} A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6)))))) (OfNat.ofNat.{u3} B 0 (OfNat.mk.{u3} B 0 (Zero.zero.{u3} B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7)))))) -> (forall (a : A) (b : A), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (degb (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toHasAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))) a b)) (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toHasAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7))) (degb a) (degb b))) -> (forall (n : Nat) (f : AddMonoidAlgebra.{u1, u2} R A _inst_5), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_5)))) (HPow.hPow.{max u2 u1, 0, max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) Nat (AddMonoidAlgebra.{u1, u2} R A _inst_5) (instHPow.{max u2 u1, 0} (AddMonoidAlgebra.{u1, u2} R A _inst_5) Nat (Monoid.Pow.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (MonoidWithZero.toMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (Semiring.toMonoidWithZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.semiring.{u1, u2} R A _inst_5 _inst_6))))) f n)) degb) (SMul.smul.{0, u3} Nat B (AddMonoid.SMul.{u3} B _inst_7) n (Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_5)))) f) degb)))
but is expected to have type
  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : SemilatticeSup.{u3} B] [_inst_2 : OrderBot.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1)))] [_inst_5 : Semiring.{u1} R] [_inst_6 : AddMonoid.{u2} A] [_inst_7 : AddMonoid.{u3} B] [_inst_8 : CovariantClass.{u3, u3} B B (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1828 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1830 : B) => HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1828 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1830) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1843 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1845 : B) => LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1843 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1845)] [_inst_9 : CovariantClass.{u3, u3} B B (Function.swap.{succ u3, succ u3, succ u3} B B (fun (ᾰ : B) (ᾰ : B) => B) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1865 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1867 : B) => HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1865 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1867)) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1880 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1882 : B) => LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1880 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.1882)] {degb : A -> B}, (LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (degb (OfNat.ofNat.{u2} A 0 (Zero.toOfNat0.{u2} A (AddMonoid.toZero.{u2} A _inst_6)))) (OfNat.ofNat.{u3} B 0 (Zero.toOfNat0.{u3} B (AddMonoid.toZero.{u3} B _inst_7)))) -> (forall (a : A) (b : A), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (degb (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))) a b)) (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B _inst_7))) (degb a) (degb b))) -> (forall (n : Nat) (f : AddMonoidAlgebra.{u1, u2} R A _inst_5), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_5)) (HPow.hPow.{max u1 u2, 0, max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) Nat (AddMonoidAlgebra.{u1, u2} R A _inst_5) (instHPow.{max u1 u2, 0} (AddMonoidAlgebra.{u1, u2} R A _inst_5) Nat (Monoid.Pow.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (MonoidWithZero.toMonoid.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (Semiring.toMonoidWithZero.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.semiring.{u1, u2} R A _inst_5 _inst_6))))) f n)) degb) (HSMul.hSMul.{0, u3, u3} Nat B B (instHSMul.{0, u3} Nat B (AddMonoid.SMul.{u3} B _inst_7)) n (Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_5)) f) degb)))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.sup_support_pow_le AddMonoidAlgebra.sup_support_pow_leₓ'. -/
theorem sup_support_pow_le (degb0 : degb 0 ≤ 0) (degbm : ∀ a b, degb (a + b) ≤ degb a + degb b)
    (n : ℕ) (f : AddMonoidAlgebra R A) : (f ^ n).support.sup degb ≤ n • f.support.sup degb :=
  by
  rw [← List.prod_replicate, ← List.sum_replicate]
  refine' (sup_support_list_prod_le degb0 degbm _).trans_eq _
  rw [List.map_replicate]
#align add_monoid_algebra.sup_support_pow_le AddMonoidAlgebra.sup_support_pow_le

/- warning: add_monoid_algebra.le_inf_support_pow -> AddMonoidAlgebra.le_inf_support_pow is a dubious translation:
lean 3 declaration is
  forall {R : Type.{u1}} {A : Type.{u2}} {T : Type.{u3}} [_inst_3 : SemilatticeInf.{u3} T] [_inst_4 : OrderTop.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3)))] [_inst_5 : Semiring.{u1} R] [_inst_6 : AddMonoid.{u2} A] [_inst_10 : AddMonoid.{u3} T] [_inst_11 : CovariantClass.{u3, u3} T T (HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toHasAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10)))) (LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))))] [_inst_12 : CovariantClass.{u3, u3} T T (Function.swap.{succ u3, succ u3, succ u3} T T (fun (ᾰ : T) (ᾰ : T) => T) (HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toHasAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10))))) (LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))))] {degt : A -> T}, (LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (OfNat.ofNat.{u3} T 0 (OfNat.mk.{u3} T 0 (Zero.zero.{u3} T (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10))))) (degt (OfNat.ofNat.{u2} A 0 (OfNat.mk.{u2} A 0 (Zero.zero.{u2} A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))))))) -> (forall (a : A) (b : A), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toHasAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10))) (degt a) (degt b)) (degt (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toHasAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))) a b))) -> (forall (n : Nat) (f : AddMonoidAlgebra.{u1, u2} R A _inst_5), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (SMul.smul.{0, u3} Nat T (AddMonoid.SMul.{u3} T _inst_10) n (Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_5)))) f) degt)) (Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_5)))) (HPow.hPow.{max u2 u1, 0, max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) Nat (AddMonoidAlgebra.{u1, u2} R A _inst_5) (instHPow.{max u2 u1, 0} (AddMonoidAlgebra.{u1, u2} R A _inst_5) Nat (Monoid.Pow.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (MonoidWithZero.toMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (Semiring.toMonoidWithZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.semiring.{u1, u2} R A _inst_5 _inst_6))))) f n)) degt))
but is expected to have type
  forall {R : Type.{u1}} {A : Type.{u2}} {T : Type.{u3}} [_inst_3 : SemilatticeInf.{u3} T] [_inst_4 : OrderTop.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3)))] [_inst_5 : Semiring.{u1} R] [_inst_6 : AddMonoid.{u2} A] [_inst_10 : AddMonoid.{u3} T] [_inst_11 : CovariantClass.{u3, u3} T T (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2198 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2200 : T) => HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2198 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2200) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2213 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2215 : T) => LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2213 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2215)] [_inst_12 : CovariantClass.{u3, u3} T T (Function.swap.{succ u3, succ u3, succ u3} T T (fun (ᾰ : T) (ᾰ : T) => T) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2235 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2237 : T) => HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2235 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2237)) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2250 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2252 : T) => LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2250 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2252)] {degt : A -> T}, (LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (OfNat.ofNat.{u3} T 0 (Zero.toOfNat0.{u3} T (AddMonoid.toZero.{u3} T _inst_10))) (degt (OfNat.ofNat.{u2} A 0 (Zero.toOfNat0.{u2} A (AddMonoid.toZero.{u2} A _inst_6))))) -> (forall (a : A) (b : A), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T _inst_10))) (degt a) (degt b)) (degt (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_6))) a b))) -> (forall (n : Nat) (f : AddMonoidAlgebra.{u1, u2} R A _inst_5), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (HSMul.hSMul.{0, u3, u3} Nat T T (instHSMul.{0, u3} Nat T (AddMonoid.SMul.{u3} T _inst_10)) n (Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_5)) f) degt)) (Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_5)) (HPow.hPow.{max u1 u2, 0, max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) Nat (AddMonoidAlgebra.{u1, u2} R A _inst_5) (instHPow.{max u1 u2, 0} (AddMonoidAlgebra.{u1, u2} R A _inst_5) Nat (Monoid.Pow.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (MonoidWithZero.toMonoid.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (Semiring.toMonoidWithZero.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A _inst_5) (AddMonoidAlgebra.semiring.{u1, u2} R A _inst_5 _inst_6))))) f n)) degt))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.le_inf_support_pow AddMonoidAlgebra.le_inf_support_powₓ'. -/
theorem le_inf_support_pow (degt0 : 0 ≤ degt 0) (degtm : ∀ a b, degt a + degt b ≤ degt (a + b))
    (n : ℕ) (f : AddMonoidAlgebra R A) : n • f.support.inf degt ≤ (f ^ n).support.inf degt :=
  OrderDual.ofDual_le_ofDual.mpr <|
    sup_support_pow_le (OrderDual.ofDual_le_ofDual.mp degt0)
      (fun a b => OrderDual.ofDual_le_ofDual.mp (degtm _ _)) n f
#align add_monoid_algebra.le_inf_support_pow AddMonoidAlgebra.le_inf_support_pow

end AddMonoids

end Semiring

section CommutativeLemmas

variable [CommSemiring R] [AddCommMonoid A] [AddCommMonoid B] [CovariantClass B B (· + ·) (· ≤ ·)]
  [CovariantClass B B (Function.swap (· + ·)) (· ≤ ·)] [AddCommMonoid T]
  [CovariantClass T T (· + ·) (· ≤ ·)] [CovariantClass T T (Function.swap (· + ·)) (· ≤ ·)]
  {degb : A → B} {degt : A → T}

/- warning: add_monoid_algebra.sup_support_multiset_prod_le -> AddMonoidAlgebra.sup_support_multiset_prod_le is a dubious translation:
lean 3 declaration is
  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : SemilatticeSup.{u3} B] [_inst_2 : OrderBot.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1)))] [_inst_5 : CommSemiring.{u1} R] [_inst_6 : AddCommMonoid.{u2} A] [_inst_7 : AddCommMonoid.{u3} B] [_inst_8 : CovariantClass.{u3, u3} B B (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toHasAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_7))))) (LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))))] [_inst_9 : CovariantClass.{u3, u3} B B (Function.swap.{succ u3, succ u3, succ u3} B B (fun (ᾰ : B) (ᾰ : B) => B) (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toHasAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_7)))))) (LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))))] {degb : A -> B}, (LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (degb (OfNat.ofNat.{u2} A 0 (OfNat.mk.{u2} A 0 (Zero.zero.{u2} A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A _inst_6))))))) (OfNat.ofNat.{u3} B 0 (OfNat.mk.{u3} B 0 (Zero.zero.{u3} B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_7))))))) -> (forall (a : A) (b : A), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (degb (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toHasAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A _inst_6)))) a b)) (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toHasAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_7)))) (degb a) (degb b))) -> (forall (m : Multiset.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5))), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))))) (Multiset.prod.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) (CommSemiring.toCommMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) (AddMonoidAlgebra.commSemiring.{u1, u2} R A _inst_5 _inst_6)) m)) degb) (Multiset.sum.{u3} B _inst_7 (Multiset.map.{max u2 u1, u3} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) B (fun (f : AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) => Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))))) f) degb) m)))
but is expected to have type
  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : SemilatticeSup.{u3} B] [_inst_2 : OrderBot.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1)))] [_inst_5 : CommSemiring.{u1} R] [_inst_6 : AddCommMonoid.{u2} A] [_inst_7 : AddCommMonoid.{u3} B] [_inst_8 : CovariantClass.{u3, u3} B B (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2571 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2573 : B) => HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_7)))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2571 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2573) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2586 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2588 : B) => LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2586 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2588)] [_inst_9 : CovariantClass.{u3, u3} B B (Function.swap.{succ u3, succ u3, succ u3} B B (fun (ᾰ : B) (ᾰ : B) => B) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2608 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2610 : B) => HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_7)))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2608 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2610)) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2623 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2625 : B) => LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2623 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2625)] {degb : A -> B}, (LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (degb (OfNat.ofNat.{u2} A 0 (Zero.toOfNat0.{u2} A (AddMonoid.toZero.{u2} A (AddCommMonoid.toAddMonoid.{u2} A _inst_6))))) (OfNat.ofNat.{u3} B 0 (Zero.toOfNat0.{u3} B (AddMonoid.toZero.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_7))))) -> (forall (a : A) (b : A), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (degb (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A _inst_6)))) a b)) (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_7)))) (degb a) (degb b))) -> (forall (m : Multiset.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5))), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))) (Multiset.prod.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) (CommSemiring.toCommMonoid.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) (AddMonoidAlgebra.commSemiring.{u1, u2} R A _inst_5 _inst_6)) m)) degb) (Multiset.sum.{u3} B _inst_7 (Multiset.map.{max u1 u2, u3} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) B (fun (f : AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) => Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))) f) degb) m)))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.sup_support_multiset_prod_le AddMonoidAlgebra.sup_support_multiset_prod_leₓ'. -/
theorem sup_support_multiset_prod_le (degb0 : degb 0 ≤ 0)
    (degbm : ∀ a b, degb (a + b) ≤ degb a + degb b) (m : Multiset (AddMonoidAlgebra R A)) :
    m.Prod.support.sup degb ≤ (m.map fun f : AddMonoidAlgebra R A => f.support.sup degb).Sum :=
  by
  induction m using Quot.inductionOn
  rw [Multiset.quot_mk_to_coe'', Multiset.coe_map, Multiset.coe_sum, Multiset.coe_prod]
  exact sup_support_list_prod_le degb0 degbm m
#align add_monoid_algebra.sup_support_multiset_prod_le AddMonoidAlgebra.sup_support_multiset_prod_le

/- warning: add_monoid_algebra.le_inf_support_multiset_prod -> AddMonoidAlgebra.le_inf_support_multiset_prod is a dubious translation:
lean 3 declaration is
  forall {R : Type.{u1}} {A : Type.{u2}} {T : Type.{u3}} [_inst_3 : SemilatticeInf.{u3} T] [_inst_4 : OrderTop.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3)))] [_inst_5 : CommSemiring.{u1} R] [_inst_6 : AddCommMonoid.{u2} A] [_inst_10 : AddCommMonoid.{u3} T] [_inst_11 : CovariantClass.{u3, u3} T T (HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toHasAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T _inst_10))))) (LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))))] [_inst_12 : CovariantClass.{u3, u3} T T (Function.swap.{succ u3, succ u3, succ u3} T T (fun (ᾰ : T) (ᾰ : T) => T) (HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toHasAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T _inst_10)))))) (LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))))] {degt : A -> T}, (LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (OfNat.ofNat.{u3} T 0 (OfNat.mk.{u3} T 0 (Zero.zero.{u3} T (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T _inst_10)))))) (degt (OfNat.ofNat.{u2} A 0 (OfNat.mk.{u2} A 0 (Zero.zero.{u2} A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A _inst_6)))))))) -> (forall (a : A) (b : A), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toHasAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T _inst_10)))) (degt a) (degt b)) (degt (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toHasAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A _inst_6)))) a b))) -> (forall (m : Multiset.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5))), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (Multiset.sum.{u3} T _inst_10 (Multiset.map.{max u2 u1, u3} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) T (fun (f : AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) => Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))))) f) degt) m)) (Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))))) (Multiset.prod.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) (CommSemiring.toCommMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) (AddMonoidAlgebra.commSemiring.{u1, u2} R A _inst_5 _inst_6)) m)) degt))
but is expected to have type
  forall {R : Type.{u1}} {A : Type.{u2}} {T : Type.{u3}} [_inst_3 : SemilatticeInf.{u3} T] [_inst_4 : OrderTop.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3)))] [_inst_5 : CommSemiring.{u1} R] [_inst_6 : AddCommMonoid.{u2} A] [_inst_10 : AddCommMonoid.{u3} T] [_inst_11 : CovariantClass.{u3, u3} T T (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2917 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2919 : T) => HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T _inst_10)))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2917 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2919) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2932 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2934 : T) => LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2932 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2934)] [_inst_12 : CovariantClass.{u3, u3} T T (Function.swap.{succ u3, succ u3, succ u3} T T (fun (ᾰ : T) (ᾰ : T) => T) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2954 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2956 : T) => HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T _inst_10)))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2954 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2956)) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2969 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2971 : T) => LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2969 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.2971)] {degt : A -> T}, (LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (OfNat.ofNat.{u3} T 0 (Zero.toOfNat0.{u3} T (AddMonoid.toZero.{u3} T (AddCommMonoid.toAddMonoid.{u3} T _inst_10)))) (degt (OfNat.ofNat.{u2} A 0 (Zero.toOfNat0.{u2} A (AddMonoid.toZero.{u2} A (AddCommMonoid.toAddMonoid.{u2} A _inst_6)))))) -> (forall (a : A) (b : A), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T _inst_10)))) (degt a) (degt b)) (degt (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A _inst_6)))) a b))) -> (forall (m : Multiset.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5))), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (Multiset.sum.{u3} T _inst_10 (Multiset.map.{max u1 u2, u3} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) T (fun (f : AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) => Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))) f) degt) m)) (Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))) (Multiset.prod.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) (CommSemiring.toCommMonoid.{max u1 u2} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) (AddMonoidAlgebra.commSemiring.{u1, u2} R A _inst_5 _inst_6)) m)) degt))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.le_inf_support_multiset_prod AddMonoidAlgebra.le_inf_support_multiset_prodₓ'. -/
theorem le_inf_support_multiset_prod (degt0 : 0 ≤ degt 0)
    (degtm : ∀ a b, degt a + degt b ≤ degt (a + b)) (m : Multiset (AddMonoidAlgebra R A)) :
    (m.map fun f : AddMonoidAlgebra R A => f.support.inf degt).Sum ≤ m.Prod.support.inf degt :=
  OrderDual.ofDual_le_ofDual.mpr <|
    sup_support_multiset_prod_le (OrderDual.ofDual_le_ofDual.mp degt0)
      (fun a b => OrderDual.ofDual_le_ofDual.mp (degtm _ _)) m
#align add_monoid_algebra.le_inf_support_multiset_prod AddMonoidAlgebra.le_inf_support_multiset_prod

/- warning: add_monoid_algebra.sup_support_finset_prod_le -> AddMonoidAlgebra.sup_support_finset_prod_le is a dubious translation:
lean 3 declaration is
  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} {ι : Type.{u4}} [_inst_1 : SemilatticeSup.{u3} B] [_inst_2 : OrderBot.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1)))] [_inst_5 : CommSemiring.{u1} R] [_inst_6 : AddCommMonoid.{u2} A] [_inst_7 : AddCommMonoid.{u3} B] [_inst_8 : CovariantClass.{u3, u3} B B (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toHasAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_7))))) (LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))))] [_inst_9 : CovariantClass.{u3, u3} B B (Function.swap.{succ u3, succ u3, succ u3} B B (fun (ᾰ : B) (ᾰ : B) => B) (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toHasAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_7)))))) (LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))))] {degb : A -> B}, (LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (degb (OfNat.ofNat.{u2} A 0 (OfNat.mk.{u2} A 0 (Zero.zero.{u2} A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A _inst_6))))))) (OfNat.ofNat.{u3} B 0 (OfNat.mk.{u3} B 0 (Zero.zero.{u3} B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_7))))))) -> (forall (a : A) (b : A), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (degb (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toHasAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A _inst_6)))) a b)) (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toHasAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_7)))) (degb a) (degb b))) -> (forall (s : Finset.{u4} ι) (f : ι -> (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5))), LE.le.{u3} B (Preorder.toLE.{u3} B (PartialOrder.toPreorder.{u3} B (SemilatticeSup.toPartialOrder.{u3} B _inst_1))) (Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))))) (Finset.prod.{max u2 u1, u4} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) ι (CommSemiring.toCommMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) (AddMonoidAlgebra.commSemiring.{u1, u2} R A _inst_5 _inst_6)) s (fun (i : ι) => f i))) degb) (Finset.sum.{u3, u4} B ι _inst_7 s (fun (i : ι) => Finset.sup.{u3, u2} B A _inst_1 _inst_2 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))))) (f i)) degb)))
but is expected to have type
  forall {R : Type.{u1}} {A : Type.{u3}} {B : Type.{u4}} {ι : Type.{u2}} [_inst_1 : SemilatticeSup.{u4} B] [_inst_2 : OrderBot.{u4} B (Preorder.toLE.{u4} B (PartialOrder.toPreorder.{u4} B (SemilatticeSup.toPartialOrder.{u4} B _inst_1)))] [_inst_5 : CommSemiring.{u1} R] [_inst_6 : AddCommMonoid.{u3} A] [_inst_7 : AddCommMonoid.{u4} B] [_inst_8 : CovariantClass.{u4, u4} B B (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3101 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3103 : B) => HAdd.hAdd.{u4, u4, u4} B B B (instHAdd.{u4} B (AddZeroClass.toAdd.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B _inst_7)))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3101 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3103) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3116 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3118 : B) => LE.le.{u4} B (Preorder.toLE.{u4} B (PartialOrder.toPreorder.{u4} B (SemilatticeSup.toPartialOrder.{u4} B _inst_1))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3116 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3118)] [_inst_9 : CovariantClass.{u4, u4} B B (Function.swap.{succ u4, succ u4, succ u4} B B (fun (ᾰ : B) (ᾰ : B) => B) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3138 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3140 : B) => HAdd.hAdd.{u4, u4, u4} B B B (instHAdd.{u4} B (AddZeroClass.toAdd.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B _inst_7)))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3138 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3140)) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3153 : B) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3155 : B) => LE.le.{u4} B (Preorder.toLE.{u4} B (PartialOrder.toPreorder.{u4} B (SemilatticeSup.toPartialOrder.{u4} B _inst_1))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3153 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3155)] {degb : A -> B}, (LE.le.{u4} B (Preorder.toLE.{u4} B (PartialOrder.toPreorder.{u4} B (SemilatticeSup.toPartialOrder.{u4} B _inst_1))) (degb (OfNat.ofNat.{u3} A 0 (Zero.toOfNat0.{u3} A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_6))))) (OfNat.ofNat.{u4} B 0 (Zero.toOfNat0.{u4} B (AddMonoid.toZero.{u4} B (AddCommMonoid.toAddMonoid.{u4} B _inst_7))))) -> (forall (a : A) (b : A), LE.le.{u4} B (Preorder.toLE.{u4} B (PartialOrder.toPreorder.{u4} B (SemilatticeSup.toPartialOrder.{u4} B _inst_1))) (degb (HAdd.hAdd.{u3, u3, u3} A A A (instHAdd.{u3} A (AddZeroClass.toAdd.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_6)))) a b)) (HAdd.hAdd.{u4, u4, u4} B B B (instHAdd.{u4} B (AddZeroClass.toAdd.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B _inst_7)))) (degb a) (degb b))) -> (forall (s : Finset.{u2} ι) (f : ι -> (AddMonoidAlgebra.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_5))), LE.le.{u4} B (Preorder.toLE.{u4} B (PartialOrder.toPreorder.{u4} B (SemilatticeSup.toPartialOrder.{u4} B _inst_1))) (Finset.sup.{u4, u3} B A _inst_1 _inst_2 (Finsupp.support.{u3, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))) (Finset.prod.{max u1 u3, u2} (AddMonoidAlgebra.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_5)) ι (CommSemiring.toCommMonoid.{max u1 u3} (AddMonoidAlgebra.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_5)) (AddMonoidAlgebra.commSemiring.{u1, u3} R A _inst_5 _inst_6)) s (fun (i : ι) => f i))) degb) (Finset.sum.{u4, u2} B ι _inst_7 s (fun (i : ι) => Finset.sup.{u4, u3} B A _inst_1 _inst_2 (Finsupp.support.{u3, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))) (f i)) degb)))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.sup_support_finset_prod_le AddMonoidAlgebra.sup_support_finset_prod_leₓ'. -/
theorem sup_support_finset_prod_le (degb0 : degb 0 ≤ 0)
    (degbm : ∀ a b, degb (a + b) ≤ degb a + degb b) (s : Finset ι) (f : ι → AddMonoidAlgebra R A) :
    (∏ i in s, f i).support.sup degb ≤ ∑ i in s, (f i).support.sup degb :=
  (sup_support_multiset_prod_le degb0 degbm _).trans_eq <| congr_arg _ <| Multiset.map_map _ _ _
#align add_monoid_algebra.sup_support_finset_prod_le AddMonoidAlgebra.sup_support_finset_prod_le

/- warning: add_monoid_algebra.le_inf_support_finset_prod -> AddMonoidAlgebra.le_inf_support_finset_prod is a dubious translation:
lean 3 declaration is
  forall {R : Type.{u1}} {A : Type.{u2}} {T : Type.{u3}} {ι : Type.{u4}} [_inst_3 : SemilatticeInf.{u3} T] [_inst_4 : OrderTop.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3)))] [_inst_5 : CommSemiring.{u1} R] [_inst_6 : AddCommMonoid.{u2} A] [_inst_10 : AddCommMonoid.{u3} T] [_inst_11 : CovariantClass.{u3, u3} T T (HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toHasAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T _inst_10))))) (LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))))] [_inst_12 : CovariantClass.{u3, u3} T T (Function.swap.{succ u3, succ u3, succ u3} T T (fun (ᾰ : T) (ᾰ : T) => T) (HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toHasAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T _inst_10)))))) (LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))))] {degt : A -> T}, (LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (OfNat.ofNat.{u3} T 0 (OfNat.mk.{u3} T 0 (Zero.zero.{u3} T (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T _inst_10)))))) (degt (OfNat.ofNat.{u2} A 0 (OfNat.mk.{u2} A 0 (Zero.zero.{u2} A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A _inst_6)))))))) -> (forall (a : A) (b : A), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (HAdd.hAdd.{u3, u3, u3} T T T (instHAdd.{u3} T (AddZeroClass.toHasAdd.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T _inst_10)))) (degt a) (degt b)) (degt (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toHasAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A _inst_6)))) a b))) -> (forall (s : Finset.{u4} ι) (f : ι -> (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5))), LE.le.{u3} T (Preorder.toLE.{u3} T (PartialOrder.toPreorder.{u3} T (SemilatticeInf.toPartialOrder.{u3} T _inst_3))) (Finset.sum.{u3, u4} T ι _inst_10 s (fun (i : ι) => Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))))) (f i)) degt)) (Finset.inf.{u3, u2} T A _inst_3 _inst_4 (Finsupp.support.{u2, u1} A R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))))) (Finset.prod.{max u2 u1, u4} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) ι (CommSemiring.toCommMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_5)) (AddMonoidAlgebra.commSemiring.{u1, u2} R A _inst_5 _inst_6)) s (fun (i : ι) => f i))) degt))
but is expected to have type
  forall {R : Type.{u1}} {A : Type.{u3}} {T : Type.{u4}} {ι : Type.{u2}} [_inst_3 : SemilatticeInf.{u4} T] [_inst_4 : OrderTop.{u4} T (Preorder.toLE.{u4} T (PartialOrder.toPreorder.{u4} T (SemilatticeInf.toPartialOrder.{u4} T _inst_3)))] [_inst_5 : CommSemiring.{u1} R] [_inst_6 : AddCommMonoid.{u3} A] [_inst_10 : AddCommMonoid.{u4} T] [_inst_11 : CovariantClass.{u4, u4} T T (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3436 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3438 : T) => HAdd.hAdd.{u4, u4, u4} T T T (instHAdd.{u4} T (AddZeroClass.toAdd.{u4} T (AddMonoid.toAddZeroClass.{u4} T (AddCommMonoid.toAddMonoid.{u4} T _inst_10)))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3436 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3438) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3451 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3453 : T) => LE.le.{u4} T (Preorder.toLE.{u4} T (PartialOrder.toPreorder.{u4} T (SemilatticeInf.toPartialOrder.{u4} T _inst_3))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3451 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3453)] [_inst_12 : CovariantClass.{u4, u4} T T (Function.swap.{succ u4, succ u4, succ u4} T T (fun (ᾰ : T) (ᾰ : T) => T) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3473 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3475 : T) => HAdd.hAdd.{u4, u4, u4} T T T (instHAdd.{u4} T (AddZeroClass.toAdd.{u4} T (AddMonoid.toAddZeroClass.{u4} T (AddCommMonoid.toAddMonoid.{u4} T _inst_10)))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3473 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3475)) (fun (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3488 : T) (x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3490 : T) => LE.le.{u4} T (Preorder.toLE.{u4} T (PartialOrder.toPreorder.{u4} T (SemilatticeInf.toPartialOrder.{u4} T _inst_3))) x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3488 x._@.Mathlib.Algebra.MonoidAlgebra.Degree._hyg.3490)] {degt : A -> T}, (LE.le.{u4} T (Preorder.toLE.{u4} T (PartialOrder.toPreorder.{u4} T (SemilatticeInf.toPartialOrder.{u4} T _inst_3))) (OfNat.ofNat.{u4} T 0 (Zero.toOfNat0.{u4} T (AddMonoid.toZero.{u4} T (AddCommMonoid.toAddMonoid.{u4} T _inst_10)))) (degt (OfNat.ofNat.{u3} A 0 (Zero.toOfNat0.{u3} A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_6)))))) -> (forall (a : A) (b : A), LE.le.{u4} T (Preorder.toLE.{u4} T (PartialOrder.toPreorder.{u4} T (SemilatticeInf.toPartialOrder.{u4} T _inst_3))) (HAdd.hAdd.{u4, u4, u4} T T T (instHAdd.{u4} T (AddZeroClass.toAdd.{u4} T (AddMonoid.toAddZeroClass.{u4} T (AddCommMonoid.toAddMonoid.{u4} T _inst_10)))) (degt a) (degt b)) (degt (HAdd.hAdd.{u3, u3, u3} A A A (instHAdd.{u3} A (AddZeroClass.toAdd.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_6)))) a b))) -> (forall (s : Finset.{u2} ι) (f : ι -> (AddMonoidAlgebra.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_5))), LE.le.{u4} T (Preorder.toLE.{u4} T (PartialOrder.toPreorder.{u4} T (SemilatticeInf.toPartialOrder.{u4} T _inst_3))) (Finset.sum.{u4, u2} T ι _inst_10 s (fun (i : ι) => Finset.inf.{u4, u3} T A _inst_3 _inst_4 (Finsupp.support.{u3, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))) (f i)) degt)) (Finset.inf.{u4, u3} T A _inst_3 _inst_4 (Finsupp.support.{u3, u1} A R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))) (Finset.prod.{max u1 u3, u2} (AddMonoidAlgebra.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_5)) ι (CommSemiring.toCommMonoid.{max u1 u3} (AddMonoidAlgebra.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_5)) (AddMonoidAlgebra.commSemiring.{u1, u3} R A _inst_5 _inst_6)) s (fun (i : ι) => f i))) degt))
Case conversion may be inaccurate. Consider using '#align add_monoid_algebra.le_inf_support_finset_prod AddMonoidAlgebra.le_inf_support_finset_prodₓ'. -/
theorem le_inf_support_finset_prod (degt0 : 0 ≤ degt 0)
    (degtm : ∀ a b, degt a + degt b ≤ degt (a + b)) (s : Finset ι) (f : ι → AddMonoidAlgebra R A) :
    (∑ i in s, (f i).support.inf degt) ≤ (∏ i in s, f i).support.inf degt :=
  le_of_eq_of_le (by rw [Multiset.map_map] <;> rfl) (le_inf_support_multiset_prod degt0 degtm _)
#align add_monoid_algebra.le_inf_support_finset_prod AddMonoidAlgebra.le_inf_support_finset_prod

end CommutativeLemmas

end GeneralResultsAssumingSemilatticeSup

end AddMonoidAlgebra


import data.real.irrational
import topology.basic
import algebra.order.floor

--OUTPUT 1
theorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=
begin
  -- Let $\alpha$ be an irrational number. Then for distinct $i, j \in \mathbb{Z}$, we must have $\{i \alpha\} \neq\{j \alpha\}$. If this were not true, then
  have h1 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
  from by auto [int.fract_eq_iff_of_irrational hα_irrat],

  -- Hence, $S:=\{\{i \alpha\} \mid i \in \mathbb{Z}\}$ is an infinite subset of $\left[0,1\right]$.
  have h2 : (λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ) ⊆ set.Icc 0 1,
  from by auto [int.fract_nonneg, int.fract_lt_one],

  -- By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$. One can thus find pairs of elements of $S$ that are arbitrarily close. Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.
  have h3 : ∃ (x : ℤ), x ∈ set.univ ∧ ∃ (y : ℤ), y ∈ set.univ ∧ int.fract (α * ↑x) ≠ int.fract (α * ↑y) ∧ int.fract (α * ↑x) - int.fract (α * ↑y) < 1,
  from by auto [h1, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.finite_univ, set.
end --Needs more than 2000 tokens!

--OUTPUT 2
theorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=
begin
  -- Let $\alpha$ be an irrational number. Then for distinct $i, j \in \mathbb{Z}$, we must have $\{i \alpha\} \neq\{j \alpha\}$. If this were not true, then
  have h1 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
  from by auto [int.fract_eq_iff, int.fract_mul, hα_irrat, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul, int.fract_eq_iff, int.fract_mul
end --Needs more than 2000 tokens!

--OUTPUT 3
theorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=
begin
  -- Let $\alpha$ be an irrational number. Then for distinct $i, j \in \mathbb{Z}$, we must have $\{i \alpha\} \neq\{j \alpha\}$.
  have h1 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
  from by auto [int.fract_eq_iff_eq_or_eq_neg_one, int.fract_neg_one_eq_neg_one, int.fract_eq_zero_iff, int.fract_eq_one_iff, int.fract_eq_neg_one_iff, int.fract_eq_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_one, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_zero, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_zero, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_zero, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_zero, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_zero, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_zero, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_zero, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_zero, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_zero, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_zero, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_zero, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_zero, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_zero, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_zero, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract_eq_zero_iff_eq_zero, int.fract_eq_zero_iff_eq_one, int.fract_eq_zero_iff_eq_neg_one, int.fract_eq_one_iff_eq_zero, int.fract_eq_neg_one_iff_eq_zero, int.fract_eq_one_iff_eq_one, int.fract_eq_neg_one_iff_eq_neg_one, int.fract
end --Needs more than 2000 tokens!

/- FEW SHOT PROMPTS TO CODEX(START)
/--`theorem`
Power Set is Closed under Intersection
Let $S$ be a set.

Let $\powerset S$ be the power set of $S$.

Then:
:$\forall A, B \in \powerset S: A \cap B \in \powerset S$
`proof`
Let $A, B \in \powerset S$.

Then by the definition of power set, $A \subseteq S$ and $B \subseteq S$.

From Intersection is Subset we have that $A \cap B \subseteq A$.

It follows from Subset Relation is Transitive that $A \cap B \subseteq S$.

Thus $A \cap B \in \powerset S$ and closure is proved.
{{qed}}
-/
theorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=
begin
  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$
  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),
  -- Then $A ⊆ S$ and $B ⊆ S$, by power set definition
  have h1 : (A ⊆ S) ∧ (B ⊆ S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],
  -- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset
  have h2 : (A ∩ B) ⊆ A, from by auto [set.inter_subset_left],
  -- Then $(A ∩ B) ⊆ S$, by subset relation is transitive
  have h3 : (A ∩ B) ⊆ S, from by auto [set.subset.trans],
  -- Hence $(A ∩ B) ∈  𝒫 S$, by power set definition
  show (A ∩ B) ∈  𝒫 S, from by auto [set.mem_powerset],
end

/--`theorem`
Square of Sum
 :$\forall x, y \in \R: \paren {x + y}^2 = x^2 + 2 x y + y^2$
`proof`
Follows from the distribution of multiplication over addition:

{{begin-eqn}}
{{eqn | l = \left({x + y}\right)^2
      | r = \left({x + y}\right) \cdot \left({x + y}\right)
}}
{{eqn | r = x \cdot \left({x + y}\right) + y \cdot \left({x + y}\right)
      | c = Real Multiplication Distributes over Addition
}}
{{eqn | r = x \cdot x + x \cdot y + y \cdot x + y \cdot y
      | c = Real Multiplication Distributes over Addition
}}
{{eqn | r = x^2 + 2xy + y^2
      | c =
}}
{{end-eqn}}
{{qed}}
-/
theorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) :=
begin
  -- expand the power
  calc (x + y)^2 = (x+y)*(x+y) : by auto [sq]
  -- distributive property of multiplication over addition gives:
  ... = x*(x+y) + y*(x+y) : by auto [add_mul]
  -- applying the above property further gives:
  ... = x*x + x*y + y*x + y*y : by auto [mul_comm, add_mul] using [ring]
  -- rearranging the terms using commutativity and adding gives:
  ... = x^2 + 2*x*y + y^2 : by auto [sq, mul_comm] using [ring]
end

/--`theorem`
Identity of Group is Unique
Let $\struct {G, \circ}$ be a group. Then there is a unique identity element $e \in G$.
`proof`
From Group has Latin Square Property, there exists a unique $x \in G$ such that:
:$a x = b$

and there exists a unique $y \in G$ such that:
:$y a = b$

Setting $b = a$, this becomes:

There exists a unique $x \in G$ such that:
:$a x = a$

and there exists a unique $y \in G$ such that:
:$y a = a$

These $x$ and $y$ are both $e$, by definition of identity element.
{{qed}}
-/
theorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=
begin
  -- Group has Latin Square Property
  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by auto using [use (a⁻¹ * b)],
  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by auto using [use b * a⁻¹],

  -- Setting $b = a$, this becomes:
  have h3 : ∀ a : G, ∃! x : G, a * x = a, from by auto [h1],
  have h4 : ∀ a : G, ∃! y : G, y * a = a, from by auto [h2],

  -- These $x$ and $y$ are both $(1 : G)$, by definition of identity element
  have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from by auto [exists_unique.unique, h3, classical.some_spec, exists_unique.exists, mul_one],
  have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from by auto [exists_unique.unique, h4, classical.some_spec, exists_unique.exists, one_mul],

  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by auto [h3, h4, exists_unique.unique, classical.some_spec, exists_unique.exists] using [use (1 : G)],
end

/--`theorem`
Squeeze Theorem for Real Numbers
Let $\sequence {x_n}$, $\sequence {y_n}$ and $\sequence {z_n}$ be sequences in $\R$.

Let $\sequence {y_n}$ and $\sequence {z_n}$ both be convergent to the following limit:
:$\ds \lim_{n \mathop \to \infty} y_n = l, \lim_{n \mathop \to \infty} z_n = l$

Suppose that:
:$\forall n \in \N: y_n \le x_n \le z_n$

Then:
:$x_n \to l$ as $n \to \infty$
that is:
:$\ds \lim_{n \mathop \to \infty} x_n = l$

`proof`
From Negative of Absolute Value:
:$\size {x - l} < \epsilon \iff l - \epsilon < x < l + \epsilon$

Let $\epsilon > 0$.

We need to prove that:
:$\exists N: \forall n > N: \size {x_n - l} < \epsilon$

As $\ds \lim_{n \mathop \to \infty} y_n = l$ we know that:
:$\exists N_1: \forall n > N_1: \size {y_n - l} < \epsilon$

As $\ds \lim_{n \mathop \to \infty} z_n = l$ we know that:
:$\exists N_2: \forall n > N_2: \size {z_n - l} < \epsilon$

Let $N = \max \set {N_1, N_2}$.

Then if $n > N$, it follows that $n > N_1$ and $n > N_2$.

So:
:$\forall n > N: l - \epsilon < y_n < l + \epsilon$
:$\forall n > N: l - \epsilon < z_n < l + \epsilon$

But:
:$\forall n \in \N: y_n \le x_n \le z_n$

So:
:$\forall n > N: l - \epsilon < y_n \le x_n \le z_n < l + \epsilon$

and so:
:$\forall n > N: l - \epsilon < x_n < l + \epsilon$

So:
:$\forall n > N: \size {x_n - l} < \epsilon$

Hence the result.
{{qed}}

-/
theorem squeeze_theorem_real_numbers (x y z : ℕ → ℝ) (l : ℝ) :
let seq_limit : (ℕ → ℝ) → ℝ → Prop :=  λ (u : ℕ → ℝ) (l : ℝ), ∀ ε > 0, ∃ N, ∀ n > N, |u n - l| < ε in
 seq_limit y l → seq_limit z l →  (∀ n : ℕ, (y n) ≤ (x n) ∧ (x n) ≤ (z n)) → seq_limit x l :=
begin
  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : ∀ (n : ℕ), y n ≤ x n ∧ x n ≤ z n) (ε),

  --From Negative of Absolute Value: $\size {x - l} < \epsilon \iff l - \epsilon < x < l + \epsilon$
  have h5 : ∀ x, |x - l| < ε ↔ (((l - ε) < x) ∧ (x < (l + ε))),
  from by auto [abs_sub_lt_iff] using [linarith],

  --Let $\epsilon > 0$.
  assume (h7 : ε > 0),

  --As $\ds \lim_{n \mathop \to \infty} y_n = l$ we know that $\exists N_1: \forall n > N_1: \size {y_n - l} < \epsilon$
  cases h2 ε h7 with N1 h8,

  --As $\ds \lim_{n \mathop \to \infty} z_n = l$ we know that $\exists N_2: \forall n > N_2: \size {z_n - l} < \epsilon$
  cases h3 ε h7 with N2 h9,

  --Let $N = \max \set {N_1, N_2}$.
  let N := max N1 N2,
  use N,

  --Then if $n > N$, it follows that $n > N_1$ and $n > N_2$.
  have h10 : ∀ n > N, n > N1 ∧ n > N2 := by auto [lt_of_le_of_lt, le_max_left, le_max_right],

  --$\forall n > N: l - \epsilon < y_n < l + \epsilon$
  --$\forall n > N: l - \epsilon < z_n < l + \epsilon$
  --$\forall n \in \N: y_n \le x_n \le z_n$
  --So $\forall n > N: l - \epsilon < y_n \le x_n \le z_n < l + \epsilon$
  have h11 : ∀ n > N, (((l - ε) < (y n)) ∧ ((y n) ≤ (x n))) ∧ (((x n) ≤ (z n)) ∧ ((z n) < l+ε)),
  from by auto [h8, h10, h5, h9],

  --$\forall n > N: l - \epsilon < x_n < l + \epsilon$
  have h15 : ∀ n > N, ((l - ε) < (x n)) ∧ ((x n) < (l+ε)),
  from by auto [h11] using [linarith],

  --So $\forall n > N: \size {x_n - l} < \epsilon$
  --Hence the result
  show  ∀ (n : ℕ), n > N → |x n - l| < ε,
  from by auto [h5, h15],

end

/--`theorem`
Density of irrational orbit
The fractional parts of the integer multiples of an irrational number form a dense subset of the unit interval
`proof`
Let $\alpha$ be an irrational number. Then for distinct $i, j \in \mathbb{Z}$, we must have $\{i \alpha\} \neq\{j \alpha\}$. If this were not true, then
$$
i \alpha-\lfloor i \alpha\rfloor=\{i \alpha\}=\{j \alpha\}=j \alpha-\lfloor j \alpha\rfloor,
$$
which yields the false statement $\alpha=\frac{\lfloor i \alpha\rfloor-\lfloor j \alpha\rfloor}{i-j} \in \mathbb{Q}$. Hence,
$$
S:=\{\{i \alpha\} \mid i \in \mathbb{Z}\}
$$
is an infinite subset of $\left[0,1\right]$.

By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$. One can thus find pairs of elements of $S$ that are arbitrarily close. Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.

To show that $S$ is dense in $[0, 1]$, consider $y \in[0,1]$, and $\epsilon>0$. Then by selecting $x \in S$ such that $\{x\}<\epsilon$ (which exists as $0$ is a limit point), and $N$ such that $N \cdot\{x\} \leq y<(N+1) \cdot\{x\}$, we get: $|y-\{N x\}|<\epsilon$.

QED
-/
theorem  irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=
FEW SHOT PROMPTS TO CODEX(END)-/


/-
Copyright (c) 2021 OpenAI. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kunhao Zheng, Stanislas Polu, David Renshaw, OpenAI GPT-f
-/
import mathzoo.imports.miniF2F

open_locale nat rat real big_operators topological_space

theorem mathd_algebra_35
  (p q : ℝ → ℝ)
  (h₀ : ∀ x, p x = 2 - x^2)
  (h₁ : ∀ x≠0, q x = 6 / x) :
  p (q 2) = -7 :=
begin
  norm_num [h₀, h₁],
end