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

Commit c7d818c

Browse files
committed
feat(data/mv_polynomial/variables): vars_bind₁ and friends (#4204)
From the Witt vector project Co-Authored-By: Rob Y. Lewis <rob.y.lewis@gmail.com>
1 parent 2313602 commit c7d818c

File tree

2 files changed

+96
-29
lines changed

2 files changed

+96
-29
lines changed

src/data/mv_polynomial/rename.lean

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro
55
-/
66

7-
import data.mv_polynomial.variables
7+
import data.mv_polynomial.basic
88

99
/-!
1010
# Renaming variables of polynomials
@@ -46,9 +46,6 @@ variables {σ τ α R S : Type*} [comm_semiring R] [comm_semiring S]
4646

4747
namespace mv_polynomial
4848

49-
-- variables {a : R} {e : ℕ} {n m : σ} {s : σ →₀ ℕ}
50-
51-
5249
section rename
5350

5451
/-- Rename all the variables in a multivariable polynomial. -/
@@ -112,21 +109,6 @@ begin
112109
exact finsupp.map_domain_injective (finsupp.map_domain_injective hf)
113110
end
114111

115-
lemma total_degree_rename_le (f : σ → τ) (p : mv_polynomial σ R) :
116-
(rename f p).total_degree ≤ p.total_degree :=
117-
finset.sup_le $ assume b,
118-
begin
119-
assume h,
120-
rw rename_eq at h,
121-
have h' := finsupp.map_domain_support h,
122-
rw finset.mem_image at h',
123-
rcases h' with ⟨s, hs, rfl⟩,
124-
rw finsupp.sum_map_domain_index,
125-
exact le_trans (le_refl _) (finset.le_sup hs),
126-
exact assume _, rfl,
127-
exact assume _ _ _, rfl
128-
end
129-
130112
section
131113
variables (f : R →+* S) (k : σ → τ) (g : τ → S) (p : mv_polynomial σ R)
132114

src/data/mv_polynomial/variables.lean

Lines changed: 95 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro
55
-/
66

7-
import data.mv_polynomial.basic
7+
import data.mv_polynomial.monad
88
import data.set.disjointed
99

1010
/-!
@@ -38,14 +38,14 @@ monomial of $P$.
3838
3939
As in other polynomial files, we typically use the notation:
4040
41-
+ `σ : Type*` (indexing the variables)
41+
+ `σ τ : Type*` (indexing the variables)
4242
4343
+ `R : Type*` `[comm_semiring R]` (the coefficients)
4444
4545
+ `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set.
4646
This will give rise to a monomial in `mv_polynomial σ R` which mathematicians might call `X^s`
4747
48-
+ `a : R`
48+
+ `r : R`
4949
5050
+ `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians
5151
@@ -64,7 +64,7 @@ universes u v w
6464
variables {R : Type u} {S : Type v}
6565

6666
namespace mv_polynomial
67-
variables {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {n m : σ} {s : σ →₀ ℕ}
67+
variablesτ : Type*} {r : R} {e : ℕ} {n m : σ} {s : σ →₀ ℕ}
6868

6969
section comm_semiring
7070
variables [comm_semiring R] {p q : mv_polynomial σ R}
@@ -198,6 +198,23 @@ begin
198198
apply mv_polynomial.support_map_subset
199199
end
200200

201+
lemma degrees_rename (f : σ → τ) (φ : mv_polynomial σ R) :
202+
(rename f φ).degrees ⊆ (φ.degrees.map f) :=
203+
begin
204+
intros i,
205+
rw [mem_degrees, multiset.mem_map],
206+
rintro ⟨d, hd, hi⟩,
207+
obtain ⟨x, rfl, hx⟩ := coeff_rename_ne_zero _ _ _ hd,
208+
simp only [map_domain, mem_support_iff] at hi,
209+
rw [sum_apply, finsupp.sum] at hi,
210+
contrapose! hi,
211+
rw [finset.sum_eq_zero],
212+
intros j hj,
213+
simp only [exists_prop, mem_degrees] at hi,
214+
specialize hi j ⟨x, hx, hj⟩,
215+
rw [single_apply, if_neg hi],
216+
end
217+
201218
lemma degrees_map_of_injective [comm_semiring S] (p : mv_polynomial σ R)
202219
{f : R →+* S} (hf : injective f) : (map f p).degrees = p.degrees :=
203220
by simp only [degrees, mv_polynomial.support_map_of_injective _ hf]
@@ -214,10 +231,10 @@ def vars (p : mv_polynomial σ R) : finset σ := p.degrees.to_finset
214231
@[simp] lemma vars_0 : (0 : mv_polynomial σ R).vars = ∅ :=
215232
by rw [vars, degrees_zero, multiset.to_finset_zero]
216233

217-
@[simp] lemma vars_monomial (h : a0) : (monomial s a).vars = s.support :=
234+
@[simp] lemma vars_monomial (h : r0) : (monomial s r).vars = s.support :=
218235
by rw [vars, degrees_monomial_eq _ _ h, finsupp.to_finset_to_multiset]
219236

220-
@[simp] lemma vars_C : (C a : mv_polynomial σ R).vars = ∅ :=
237+
@[simp] lemma vars_C : (C r : mv_polynomial σ R).vars = ∅ :=
221238
by rw [vars, degrees_C, multiset.to_finset_zero]
222239

223240
@[simp] lemma vars_X (h : 0 ≠ (1 : R)) : (X n : mv_polynomial σ R).vars = {n} :=
@@ -521,16 +538,30 @@ begin
521538
{ exact lt_of_le_of_lt (nat.zero_le _) h, }
522539
end
523540

541+
lemma total_degree_rename_le (f : σ → τ) (p : mv_polynomial σ R) :
542+
(rename f p).total_degree ≤ p.total_degree :=
543+
finset.sup_le $ assume b,
544+
begin
545+
assume h,
546+
rw rename_eq at h,
547+
have h' := finsupp.map_domain_support h,
548+
rw finset.mem_image at h',
549+
rcases h' with ⟨s, hs, rfl⟩,
550+
rw finsupp.sum_map_domain_index,
551+
exact le_trans (le_refl _) (finset.le_sup hs),
552+
exact assume _, rfl,
553+
exact assume _ _ _, rfl
554+
end
555+
524556
end total_degree
525557

526558
section eval_vars
527559

528560
/-! ### `vars` and `eval` -/
529561

530-
variables {S₁ : Type v} {S₂ : Type w} (f : σ → S₁)
531-
variables [comm_semiring S₁] [algebra R S₁] [comm_semiring S₂]
562+
variables [comm_semiring S]
532563

533-
lemma eval₂_hom_eq_constant_coeff_of_vars (f : R →+* S) {g : σ → S}
564+
lemma eval₂_hom_eq_constant_coeff_of_vars (f : R →+* S) {g : σ → S}
534565
{p : mv_polynomial σ R} (hp : ∀ i ∈ p.vars, g i = 0) :
535566
eval₂_hom f g p = f (constant_coeff p) :=
536567
begin
@@ -558,11 +589,65 @@ begin
558589
intro, contradiction }
559590
end
560591

561-
lemma aeval_eq_constant_coeff_of_vars [algebra R S] {g : σ → S}
592+
lemma aeval_eq_constant_coeff_of_vars [algebra R S] {g : σ → S}
562593
{p : mv_polynomial σ R} (hp : ∀ i ∈ p.vars, g i = 0) :
563594
aeval g p = algebra_map _ _ (constant_coeff p) :=
564595
eval₂_hom_eq_constant_coeff_of_vars _ hp
565596

597+
lemma eval₂_hom_congr' {f₁ f₂ : R →+* S} {g₁ g₂ : σ → S} {p₁ p₂ : mv_polynomial σ R} :
598+
f₁ = f₂ → (∀ i, i ∈ p₁.vars → i ∈ p₂.vars → g₁ i = g₂ i) → p₁ = p₂ →
599+
eval₂_hom f₁ g₁ p₁ = eval₂_hom f₂ g₂ p₂ :=
600+
begin
601+
rintro rfl h rfl,
602+
rename [p₁ p, f₁ f],
603+
rw p.as_sum,
604+
simp only [ring_hom.map_sum, eval₂_hom_monomial],
605+
apply finset.sum_congr rfl,
606+
intros d hd,
607+
congr' 1,
608+
simp only [finsupp.prod],
609+
apply finset.prod_congr rfl,
610+
intros i hi,
611+
have : i ∈ p.vars, { rw mem_vars, exact ⟨d, hd, hi⟩ },
612+
rw h i this this,
613+
end
614+
615+
lemma vars_bind₁ (f : σ → mv_polynomial τ R) (φ : mv_polynomial σ R) :
616+
(bind₁ f φ).vars ⊆ φ.vars.bind (λ i, (f i).vars) :=
617+
begin
618+
calc (bind₁ f φ).vars
619+
= (φ.support.sum (λ (x : σ →₀ ℕ), (bind₁ f) (monomial x (coeff x φ)))).vars :
620+
by { rw [← alg_hom.map_sum, ← φ.as_sum], }
621+
... ≤ φ.support.bind (λ (i : σ →₀ ℕ), ((bind₁ f) (monomial i (coeff i φ))).vars) : vars_sum_subset _ _
622+
... = φ.support.bind (λ (d : σ →₀ ℕ), (C (coeff d φ) * ∏ i in d.support, f i ^ d i).vars) :
623+
by simp only [bind₁_monomial]
624+
... ≤ φ.support.bind (λ (d : σ →₀ ℕ), d.support.bind (λ i, (f i).vars)) : _ -- proof below
625+
... ≤ φ.vars.bind (λ (i : σ), (f i).vars) : _, -- proof below
626+
{ apply finset.bind_mono,
627+
intros d hd,
628+
calc (C (coeff d φ) * ∏ (i : σ) in d.support, f i ^ d i).vars
629+
≤ (C (coeff d φ)).vars ∪ (∏ (i : σ) in d.support, f i ^ d i).vars : vars_mul _ _
630+
... ≤ (∏ (i : σ) in d.support, f i ^ d i).vars :
631+
by simp only [finset.empty_union, vars_C, finset.le_iff_subset, finset.subset.refl]
632+
... ≤ d.support.bind (λ (i : σ), (f i ^ d i).vars) : vars_prod _
633+
... ≤ d.support.bind (λ (i : σ), (f i).vars) : _,
634+
apply finset.bind_mono,
635+
intros i hi,
636+
apply vars_pow, },
637+
{ intro j,
638+
simp_rw finset.mem_bind,
639+
rintro ⟨d, hd, ⟨i, hi, hj⟩⟩,
640+
exact ⟨i, (mem_vars _).mpr ⟨d, hd, hi⟩, hj⟩ }
641+
end
642+
643+
lemma vars_rename (f : σ → τ) (φ : mv_polynomial σ R) :
644+
(rename f φ).vars ⊆ (φ.vars.image f) :=
645+
begin
646+
intros i hi,
647+
simp only [vars, exists_prop, multiset.mem_to_finset, finset.mem_image] at hi ⊢,
648+
simpa only [multiset.mem_map] using degrees_rename _ _ hi
649+
end
650+
566651
end eval_vars
567652

568653
end comm_semiring

0 commit comments

Comments
 (0)