Theorem: LaurentPolynomial.trunc_C_mul_T
File: Mathlib/Data/Polynomial/Laurent.lean

tactic: have : Function.Injective Int.ofNat := fun x y h => Int.ofNat_inj.mp h
state_before: R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
⊢ ↑trunc (↑C r * T n) = if 0 ≤ n then ↑(monomial (Int.toNat n)) r else 0

tactic: apply (toFinsuppIso R).injective
state_before: R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
this : Function.Injective Int.ofNat
⊢ ↑trunc (↑C r * T n) = if 0 ≤ n then ↑(monomial (Int.toNat n)) r else 0

tactic: rw [← single_eq_C_mul_T, trunc, AddMonoidHom.coe_comp, Function.comp_apply]
state_before: case a
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
this : Function.Injective Int.ofNat
⊢ ↑(toFinsuppIso R) (↑trunc (↑C r * T n)) = ↑(toFinsuppIso R) (if 0 ≤ n then ↑(monomial (Int.toNat n)) r else 0)

tactic: erw [comapDomain.addMonoidHom_apply this]
state_before: case a
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
this : Function.Injective Int.ofNat
⊢ ↑(toFinsuppIso R)
      (↑(RingEquiv.toAddMonoidHom (RingEquiv.symm (toFinsuppIso R)))
        (↑(comapDomain.addMonoidHom trunc.proof_1) (Finsupp.single n r))) =
    ↑(toFinsuppIso R) (if 0 ≤ n then ↑(monomial (Int.toNat n)) r else 0)

tactic: rw [toFinsuppIso_apply]
state_before: case a
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
this : Function.Injective Int.ofNat
⊢ comapDomain Int.ofNat (Finsupp.single n r) (_ : Set.InjOn Int.ofNat (Int.ofNat ⁻¹' ↑(Finsupp.single n r).support)) =
    ↑(toFinsuppIso R) (if 0 ≤ n then ↑(monomial (Int.toNat n)) r else 0)

tactic: by_cases n0 : 0 ≤ n
state_before: case a
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
this : Function.Injective Int.ofNat
⊢ comapDomain Int.ofNat (Finsupp.single n r) (_ : Set.InjOn Int.ofNat (Int.ofNat ⁻¹' ↑(Finsupp.single n r).support)) =
    (if 0 ≤ n then ↑(monomial (Int.toNat n)) r else 0).toFinsupp

tactic: lift n to ℕ using n0
state_before: case pos
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
this : Function.Injective Int.ofNat
n0 : 0 ≤ n
⊢ comapDomain Int.ofNat (Finsupp.single n r) (_ : Set.InjOn Int.ofNat (Int.ofNat ⁻¹' ↑(Finsupp.single n r).support)) =
    (if 0 ≤ n then ↑(monomial (Int.toNat n)) r else 0).toFinsupp

tactic: erw [comapDomain_single]
state_before: case pos.intro
R : Type u_1
inst✝ : Semiring R
r : R
this : Function.Injective Int.ofNat
n : ℕ
⊢ comapDomain Int.ofNat (Finsupp.single (↑n) r)
      (_ : Set.InjOn Int.ofNat (Int.ofNat ⁻¹' ↑(Finsupp.single (↑n) r).support)) =
    (if 0 ≤ ↑n then ↑(monomial (Int.toNat ↑n)) r else 0).toFinsupp

tactic: simp only [Nat.cast_nonneg, Int.toNat_ofNat, ite_true, toFinsupp_monomial]
state_before: case pos.intro
R : Type u_1
inst✝ : Semiring R
r : R
this : Function.Injective Int.ofNat
n : ℕ
⊢ Finsupp.single n r = (if 0 ≤ ↑n then ↑(monomial (Int.toNat ↑n)) r else 0).toFinsupp

tactic: lift -n to ℕ using (neg_pos.mpr (not_le.mp n0)).le with m
state_before: case neg
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
this : Function.Injective Int.ofNat
n0 : ¬0 ≤ n
⊢ comapDomain Int.ofNat (Finsupp.single n r) (_ : Set.InjOn Int.ofNat (Int.ofNat ⁻¹' ↑(Finsupp.single n r).support)) =
    (if 0 ≤ n then ↑(monomial (Int.toNat n)) r else 0).toFinsupp

tactic: rw [toFinsupp_inj, if_neg n0]
state_before: case neg.intro
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
this : Function.Injective Int.ofNat
n0 : ¬0 ≤ n
m : ℕ
trunc_C_mul_T✝ trunc_C_mul_T : ∀ (n : ℤ) (r : R), ↑trunc (↑C r * T n) = if 0 ≤ n then ↑(monomial (Int.toNat n)) r else 0
⊢ comapDomain Int.ofNat (Finsupp.single n r) (_ : Set.InjOn Int.ofNat (Int.ofNat ⁻¹' ↑(Finsupp.single n r).support)) =
    (if 0 ≤ n then ↑(monomial (Int.toNat n)) r else 0).toFinsupp

tactic: ext a
state_before: case neg.intro
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
this : Function.Injective Int.ofNat
n0 : ¬0 ≤ n
m : ℕ
trunc_C_mul_T✝ trunc_C_mul_T : ∀ (n : ℤ) (r : R), ↑trunc (↑C r * T n) = if 0 ≤ n then ↑(monomial (Int.toNat n)) r else 0
⊢ {
      toFinsupp :=
        comapDomain Int.ofNat (Finsupp.single n r)
          (_ : Set.InjOn Int.ofNat (Int.ofNat ⁻¹' ↑(Finsupp.single n r).support)) } =
    0

tactic: have := ((not_le.mp n0).trans_le (Int.ofNat_zero_le a)).ne
state_before: case neg.intro.a
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
this : Function.Injective Int.ofNat
n0 : ¬0 ≤ n
m : ℕ
trunc_C_mul_T✝ trunc_C_mul_T : ∀ (n : ℤ) (r : R), ↑trunc (↑C r * T n) = if 0 ≤ n then ↑(monomial (Int.toNat n)) r else 0
a : ℕ
⊢ coeff
      {
        toFinsupp :=
          comapDomain Int.ofNat (Finsupp.single n r)
            (_ : Set.InjOn Int.ofNat (Int.ofNat ⁻¹' ↑(Finsupp.single n r).support)) }
      a =
    coeff 0 a

tactic: simp only [coeff_ofFinsupp, comapDomain_apply, Int.ofNat_eq_coe, coeff_zero,
  single_eq_of_ne this]
state_before: case neg.intro.a
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
this✝ : Function.Injective Int.ofNat
n0 : ¬0 ≤ n
m : ℕ
trunc_C_mul_T✝ trunc_C_mul_T : ∀ (n : ℤ) (r : R), ↑trunc (↑C r * T n) = if 0 ≤ n then ↑(monomial (Int.toNat n)) r else 0
a : ℕ
this : n ≠ ↑a
⊢ coeff
      {
        toFinsupp :=
          comapDomain Int.ofNat (Finsupp.single n r)
            (_ : Set.InjOn Int.ofNat (Int.ofNat ⁻¹' ↑(Finsupp.single n r).support)) }
      a =
    coeff 0 a