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

tactic: apply (toFinsuppIso R).injective
state_before: R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
⊢ trunc (C r * T n) = if 0 ≤ n then (monomial n.toNat) r else 0
state_after: case a
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
⊢ (toFinsuppIso R) (trunc (C r * T n)) = (toFinsuppIso R) (if 0 ≤ n then (monomial n.toNat) 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
⊢ (toFinsuppIso R) (trunc (C r * T n)) = (toFinsuppIso R) (if 0 ≤ n then (monomial n.toNat) r else 0)
state_after: case a
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
⊢ (toFinsuppIso R) ((toFinsuppIso R).symm.toAddMonoidHom ((comapDomain.addMonoidHom ⋯) (Finsupp.single n r))) =
    (toFinsuppIso R) (if 0 ≤ n then (monomial n.toNat) r else 0)

tactic: erw [comapDomain.addMonoidHom_apply Int.ofNat_injective]
state_before: case a
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
⊢ (toFinsuppIso R) ((toFinsuppIso R).symm.toAddMonoidHom ((comapDomain.addMonoidHom ⋯) (Finsupp.single n r))) =
    (toFinsuppIso R) (if 0 ≤ n then (monomial n.toNat) r else 0)
state_after: case a
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
⊢ comapDomain Int.ofNat (Finsupp.single n r) ⋯ = (toFinsuppIso R) (if 0 ≤ n then (monomial n.toNat) r else 0)

tactic: rw [toFinsuppIso_apply]
state_before: case a
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
⊢ comapDomain Int.ofNat (Finsupp.single n r) ⋯ = (toFinsuppIso R) (if 0 ≤ n then (monomial n.toNat) r else 0)
state_after: case a
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
⊢ comapDomain Int.ofNat (Finsupp.single n r) ⋯ = (if 0 ≤ n then (monomial n.toNat) r else 0).toFinsupp

tactic: by_cases n0 : 0 ≤ n
state_before: case a
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
⊢ comapDomain Int.ofNat (Finsupp.single n r) ⋯ = (if 0 ≤ n then (monomial n.toNat) r else 0).toFinsupp
state_after: case pos
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
n0 : 0 ≤ n
⊢ comapDomain Int.ofNat (Finsupp.single n r) ⋯ = (if 0 ≤ n then (monomial n.toNat) r else 0).toFinsupp

case neg
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
n0 : ¬0 ≤ n
⊢ comapDomain Int.ofNat (Finsupp.single n r) ⋯ = (if 0 ≤ n then (monomial n.toNat) r else 0).toFinsupp

tactic: lift n to ℕ using n0
state_before: case pos
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
n0 : 0 ≤ n
⊢ comapDomain Int.ofNat (Finsupp.single n r) ⋯ = (if 0 ≤ n then (monomial n.toNat) r else 0).toFinsupp
state_after: case pos.intro
R : Type u_1
inst✝ : Semiring R
r : R
n : ℕ
⊢ comapDomain Int.ofNat (Finsupp.single (↑n) r) ⋯ = (if 0 ≤ ↑n then (monomial (↑n).toNat) r else 0).toFinsupp

tactic: erw [comapDomain_single]
state_before: case pos.intro
R : Type u_1
inst✝ : Semiring R
r : R
n : ℕ
⊢ comapDomain Int.ofNat (Finsupp.single (↑n) r) ⋯ = (if 0 ≤ ↑n then (monomial (↑n).toNat) r else 0).toFinsupp
state_after: case pos.intro
R : Type u_1
inst✝ : Semiring R
r : R
n : ℕ
⊢ Finsupp.single n r = (if 0 ≤ ↑n then (monomial (↑n).toNat) 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
n : ℕ
⊢ Finsupp.single n r = (if 0 ≤ ↑n then (monomial (↑n).toNat) r else 0).toFinsupp
state_after: no goals

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
n0 : ¬0 ≤ n
⊢ comapDomain Int.ofNat (Finsupp.single n r) ⋯ = (if 0 ≤ n then (monomial n.toNat) r else 0).toFinsupp
state_after: case neg.intro
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
n0 : ¬0 ≤ n
m : ℕ
⊢ comapDomain Int.ofNat (Finsupp.single n r) ⋯ = (if 0 ≤ n then (monomial n.toNat) 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
n0 : ¬0 ≤ n
m : ℕ
⊢ comapDomain Int.ofNat (Finsupp.single n r) ⋯ = (if 0 ≤ n then (monomial n.toNat) r else 0).toFinsupp
state_after: case neg.intro
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
n0 : ¬0 ≤ n
m : ℕ
⊢ { toFinsupp := comapDomain Int.ofNat (Finsupp.single n r) ⋯ } = 0

tactic: ext a
state_before: case neg.intro
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
n0 : ¬0 ≤ n
m : ℕ
⊢ { toFinsupp := comapDomain Int.ofNat (Finsupp.single n r) ⋯ } = 0
state_after: case neg.intro.a
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
n0 : ¬0 ≤ n
m a : ℕ
⊢ { toFinsupp := comapDomain Int.ofNat (Finsupp.single n r) ⋯ }.coeff a = coeff 0 a

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
n0 : ¬0 ≤ n
m a : ℕ
⊢ { toFinsupp := comapDomain Int.ofNat (Finsupp.single n r) ⋯ }.coeff a = coeff 0 a
state_after: case neg.intro.a
R : Type u_1
inst✝ : Semiring R
n : ℤ
r : R
n0 : ¬0 ≤ n
m a : ℕ
this : n ≠ ↑a
⊢ { toFinsupp := comapDomain Int.ofNat (Finsupp.single n r) ⋯ }.coeff 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
n0 : ¬0 ≤ n
m a : ℕ
this : n ≠ ↑a
⊢ { toFinsupp := comapDomain Int.ofNat (Finsupp.single n r) ⋯ }.coeff a = coeff 0 a
state_after: no goals