Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit e78563c

Browse files
feat(ring_theory/power_series): reindex trunc of a power series to truncate below index n (#10891)
Currently the definition of truncation of a univariate and multivariate power series truncates above the index, that is if we truncate a power series $\sum a_i x^i$ at index `n` the term $a_n x^n$ is included. This makes it impossible to truncate the first monomial $x^0$ away as it is included with the smallest possible value of n, which causes some issues in applications (imagine if you could only pop elements of lists if the result was non-empty!). Co-authored-by: YaelDillies <yael.dillies@gmail.com>
1 parent 6b4e269 commit e78563c

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/ring_theory/power_series/basic.lean

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ We provide the natural inclusion from polynomials to formal power series.
2828
The file starts with setting up the (semi)ring structure on multivariate power series.
2929
3030
`trunc n φ` truncates a formal power series to the polynomial
31-
that has the same coefficients as `φ`, for all `m n`, and `0` otherwise.
31+
that has the same coefficients as `φ`, for all `m < n`, and `0` otherwise.
3232
3333
If the constant coefficient of a formal power series is invertible,
3434
then this formal power series is invertible.
@@ -486,10 +486,10 @@ variables [comm_semiring R] (n : σ →₀ ℕ)
486486

487487
/-- Auxiliary definition for the truncation function. -/
488488
def trunc_fun (φ : mv_power_series σ R) : mv_polynomial σ R :=
489-
∑ m in finset.Iic n, mv_polynomial.monomial m (coeff R m φ)
489+
∑ m in finset.Iio n, mv_polynomial.monomial m (coeff R m φ)
490490

491491
lemma coeff_trunc_fun (m : σ →₀ ℕ) (φ : mv_power_series σ R) :
492-
(trunc_fun n φ).coeff m = if m n then coeff R m φ else 0 :=
492+
(trunc_fun n φ).coeff m = if m < n then coeff R m φ else 0 :=
493493
by simp [trunc_fun, mv_polynomial.coeff_sum]
494494

495495
variable (R)
@@ -503,26 +503,26 @@ def trunc : mv_power_series σ R →+ mv_polynomial σ R :=
503503
variable {R}
504504

505505
lemma coeff_trunc (m : σ →₀ ℕ) (φ : mv_power_series σ R) :
506-
(trunc R n φ).coeff m = if m n then coeff R m φ else 0 :=
506+
(trunc R n φ).coeff m = if m < n then coeff R m φ else 0 :=
507507
by simp [trunc, coeff_trunc_fun]
508508

509-
@[simp] lemma trunc_one : trunc R n 1 = 1 :=
509+
@[simp] lemma trunc_one (hnn : n ≠ 0) : trunc R n 1 = 1 :=
510510
mv_polynomial.ext _ _ $ λ m,
511511
begin
512512
rw [coeff_trunc, coeff_one],
513513
split_ifs with H H' H',
514514
{ subst m, simp },
515515
{ symmetry, rw mv_polynomial.coeff_one, exact if_neg (ne.symm H'), },
516516
{ symmetry, rw mv_polynomial.coeff_one, refine if_neg _,
517-
intro H', apply H, subst m, intro s, exact nat.zero_le _ }
517+
intro H', apply H, subst m, exact ne.bot_lt hnn, }
518518
end
519519

520-
@[simp] lemma trunc_C (a : R) : trunc R n (C σ R a) = mv_polynomial.C a :=
520+
@[simp] lemma trunc_C (hnn : n ≠ 0) (a : R) : trunc R n (C σ R a) = mv_polynomial.C a :=
521521
mv_polynomial.ext _ _ $ λ m,
522522
begin
523523
rw [coeff_trunc, coeff_C, mv_polynomial.coeff_C],
524524
split_ifs with H; refl <|> try {simp * at *},
525-
exfalso, apply H, subst m, intro s, exact nat.zero_le _
525+
exfalso, apply H, subst m, exact ne.bot_lt hnn,
526526
end
527527

528528
end trunc
@@ -1291,10 +1291,10 @@ section trunc
12911291

12921292
/-- The `n`th truncation of a formal power series to a polynomial -/
12931293
def trunc (n : ℕ) (φ : power_series R) : polynomial R :=
1294-
∑ m in Ico 0 (n + 1), polynomial.monomial m (coeff R m φ)
1294+
∑ m in Ico 0 n, polynomial.monomial m (coeff R m φ)
12951295

12961296
lemma coeff_trunc (m) (n) (φ : power_series R) :
1297-
(trunc n φ).coeff m = if m n then coeff R m φ else 0 :=
1297+
(trunc n φ).coeff m = if m < n then coeff R m φ else 0 :=
12981298
by simp [trunc, polynomial.coeff_sum, polynomial.coeff_monomial, nat.lt_succ_iff]
12991299

13001300
@[simp] lemma trunc_zero (n) : trunc n (0 : power_series R) = 0 :=
@@ -1304,20 +1304,19 @@ begin
13041304
split_ifs; refl
13051305
end
13061306

1307-
@[simp] lemma trunc_one (n) : trunc n (1 : power_series R) = 1 :=
1307+
@[simp] lemma trunc_one (n) : trunc (n + 1) (1 : power_series R) = 1 :=
13081308
polynomial.ext $ λ m,
13091309
begin
13101310
rw [coeff_trunc, coeff_one],
13111311
split_ifs with H H' H'; rw [polynomial.coeff_one],
13121312
{ subst m, rw [if_pos rfl] },
13131313
{ symmetry, exact if_neg (ne.elim (ne.symm H')) },
13141314
{ symmetry, refine if_neg _,
1315-
intro H', apply H, subst m, exact nat.zero_le _ }
1315+
intro H', apply H, subst m, exact nat.zero_lt_succ _ }
13161316
end
13171317

1318-
@[simp] lemma trunc_C (n) (a : R) : trunc n (C R a) = polynomial.C a :=
1318+
@[simp] lemma trunc_C (n) (a : R) : trunc (n + 1) (C R a) = polynomial.C a :=
13191319
polynomial.ext $ λ m,
1320-
13211320
begin
13221321
rw [coeff_trunc, coeff_C, polynomial.coeff_C],
13231322
split_ifs with H; refl <|> try {simp * at *}

0 commit comments

Comments
 (0)