Theorem: WittVector.coeff_add_of_disjoint
File: Mathlib/RingTheory/WittVector/InitTail.lean

tactic: let P : ℕ → Prop := fun n => y.coeff n = 0
state_before: p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
⊢ (x + y).coeff n = x.coeff n + y.coeff n
state_after: p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
⊢ (x + y).coeff n = x.coeff n + y.coeff n

tactic: haveI : DecidablePred P := Classical.decPred P
state_before: p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
⊢ (x + y).coeff n = x.coeff n + y.coeff n
state_after: p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
⊢ (x + y).coeff n = x.coeff n + y.coeff n

tactic: set z := mk p fun n => if P n then x.coeff n else y.coeff n
state_before: p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
⊢ (x + y).coeff n = x.coeff n + y.coeff n
state_after: p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
⊢ (x + y).coeff n = x.coeff n + y.coeff n

tactic: ext1 n
state_before: p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
⊢ select P z = x
state_after: case h
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
n : ℕ
⊢ (select P z).coeff n = x.coeff n

tactic: rw [select, coeff_mk, coeff_mk]
state_before: case h
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
n : ℕ
⊢ (select P z).coeff n = x.coeff n
state_after: case h
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
n : ℕ
⊢ (if P n then if P n then x.coeff n else y.coeff n else 0) = x.coeff n

tactic: split_ifs with hn
state_before: case h
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
n : ℕ
⊢ (if P n then if P n then x.coeff n else y.coeff n else 0) = x.coeff n
state_after: case pos
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
n : ℕ
hn : P n
⊢ x.coeff n = x.coeff n

case neg
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
n : ℕ
hn : ¬P n
⊢ 0 = x.coeff n

tactic: rfl
state_before: case pos
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
n : ℕ
hn : P n
⊢ x.coeff n = x.coeff n
state_after: no goals

tactic: rw [(h n).resolve_right hn]
state_before: case neg
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
n : ℕ
hn : ¬P n
⊢ 0 = x.coeff n
state_after: no goals

tactic: ext1 n
state_before: p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
⊢ select (fun i => ¬P i) z = y
state_after: case h
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
n : ℕ
⊢ (select (fun i => ¬P i) z).coeff n = y.coeff n

tactic: rw [select, coeff_mk, coeff_mk]
state_before: case h
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
n : ℕ
⊢ (select (fun i => ¬P i) z).coeff n = y.coeff n
state_after: case h
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
n : ℕ
⊢ (if ¬P n then if P n then x.coeff n else y.coeff n else 0) = y.coeff n

tactic: split_ifs with hn
state_before: case h
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
n : ℕ
⊢ (if ¬P n then if P n then x.coeff n else y.coeff n else 0) = y.coeff n
state_after: case pos
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
n : ℕ
hn : P n
⊢ 0 = y.coeff n

case neg
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
n : ℕ
hn : ¬P n
⊢ y.coeff n = y.coeff n

tactic: exact hn.symm
state_before: case pos
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
n : ℕ
hn : P n
⊢ 0 = y.coeff n
state_after: no goals

tactic: rfl
state_before: case neg
p : ℕ
hp : Fact (Nat.Prime p)
n✝ : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
n : ℕ
hn : ¬P n
⊢ y.coeff n = y.coeff n
state_after: no goals

tactic: rw [← hx, ← hy, select_add_select_not P z]
state_before: p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
hy : select (fun i => ¬P i) z = y
⊢ (x + y).coeff n = z.coeff n
state_after: no goals

tactic: simp only [z, mk.eq_1]
state_before: p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
hy : select (fun i => ¬P i) z = y
⊢ z.coeff n = x.coeff n + y.coeff n
state_after: p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
hy : select (fun i => ¬P i) z = y
⊢ (if P n then x.coeff n else y.coeff n) = x.coeff n + y.coeff n

tactic: split_ifs with y0
state_before: p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
hy : select (fun i => ¬P i) z = y
⊢ (if P n then x.coeff n else y.coeff n) = x.coeff n + y.coeff n
state_after: case pos
p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
hy : select (fun i => ¬P i) z = y
y0 : P n
⊢ x.coeff n = x.coeff n + y.coeff n

case neg
p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
hy : select (fun i => ¬P i) z = y
y0 : ¬P n
⊢ y.coeff n = x.coeff n + y.coeff n

tactic: rw [y0, add_zero]
state_before: case pos
p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
hy : select (fun i => ¬P i) z = y
y0 : P n
⊢ x.coeff n = x.coeff n + y.coeff n
state_after: no goals

tactic: rw [h n |>.resolve_right y0, zero_add]
state_before: case neg
p : ℕ
hp : Fact (Nat.Prime p)
n : ℕ
R : Type u_1
inst✝ : CommRing R
P✝ : ℕ → Prop
x y : 𝕎 R
h : ∀ (n : ℕ), x.coeff n = 0 ∨ y.coeff n = 0
P : ℕ → Prop := fun n => y.coeff n = 0
this : DecidablePred P
z : 𝕎 R := mk p fun n => if P n then x.coeff n else y.coeff n
hx : select P z = x
hy : select (fun i => ¬P i) z = y
y0 : ¬P n
⊢ y.coeff n = x.coeff n + y.coeff n
state_after: no goals