@@ -204,12 +204,53 @@ lemma exists_image_comap_of_monic (f g : R[X]) (hg : g.Monic) :
204204
205205universe u
206206
207- example {R} (n : ℕ) (f : Fin n → R) (a : R) : Fin (n + 1 ) → R := Fin.cons a f
207+ lemma Prod.Lex.lt_iff' {α β} [PartialOrder α] [Preorder β] (x y : α) (w z : β) :
208+ toLex (x, w) < toLex (y, z) ↔ x ≤ y ∧ (x = y → w < z) := by
209+ rw [Prod.Lex.lt_iff]
210+ simp only [lt_iff_le_not_le, le_antisymm_iff]
211+ tauto
208212
209213@[simp]
210214lemma Ideal.span_singleton_zero : Ideal.span {0 } = (⊥ : Ideal R) := by simp
211215-- Fin n → ℕ × Prop
212216
217+ lemma Polynomial.monic_unit_leadingCoeff_inv_smul
218+ (p : R[X]) (h : IsUnit p.leadingCoeff) :
219+ (((h.unit ⁻¹ : Rˣ) : R) • p).Monic := by
220+ nontriviality R
221+ rw [Monic.def, ← coeff_natDegree, Algebra.smul_def, algebraMap_eq,
222+ natDegree_C_mul_eq_of_mul_ne_zero, coeff_C_mul, coeff_natDegree, IsUnit.val_inv_mul]
223+ rw [IsUnit.val_inv_mul]
224+ exact one_ne_zero
225+
226+ lemma Ideal.span_range_update_divByMonic {ι : Type *} [DecidableEq ι]
227+ (v : ι → R[X]) (i j : ι) (hij : i ≠ j) (h : IsUnit (v i).leadingCoeff) :
228+ Ideal.span (Set.range (Function.update v j (v j %ₘ (((h.unit ⁻¹ : Rˣ) : R) • v i)))) =
229+ Ideal.span (Set.range v) := by
230+ have H : (((h.unit ⁻¹ : Rˣ) : R) • v i).Monic :=
231+ Polynomial.monic_unit_leadingCoeff_inv_smul (v i) h
232+ refine le_antisymm ?_ ?_ <;>
233+ simp only [Ideal.span_le, Set.range_subset_iff, SetLike.mem_coe]
234+ · intro k
235+ by_cases hjk : j = k
236+ · subst hjk
237+ rw [Function.update_same, modByMonic_eq_sub_mul_div (v j) H, Algebra.smul_def]
238+ apply sub_mem (Ideal.subset_span ?_) (Ideal.mul_mem_right _ _
239+ (Ideal.mul_mem_left _ _ <| Ideal.subset_span ?_))
240+ · exact ⟨j, rfl⟩
241+ · exact ⟨i, rfl⟩
242+ exact Ideal.subset_span ⟨k, (Function.update_noteq (.symm hjk) _ _).symm⟩
243+ · intro k
244+ by_cases hjk : j = k
245+ · subst hjk
246+ nth_rw 2 [← modByMonic_add_div (v j) H]
247+ rw [Algebra.smul_def]
248+ apply add_mem (Ideal.subset_span ?_) (Ideal.mul_mem_right _ _
249+ (Ideal.mul_mem_left _ _ <| Ideal.subset_span ?_))
250+ · exact ⟨j, Function.update_same _ _ _⟩
251+ · exact ⟨i, Function.update_noteq hij _ _⟩
252+ exact Ideal.subset_span ⟨k, Function.update_noteq (.symm hjk) _ _⟩
253+
213254lemma foo_induction
214255 (P : ∀ (R : Type u) [CommRing R], Ideal R[X] → Prop )
215256 (hP : ∀ (R) [CommRing R] (c : R) (I : Ideal R[X]),
@@ -224,26 +265,106 @@ lemma foo_induction
224265 exact ⟨s.card, Fin.cons 0 (Subtype.val ∘ s.equivFin.symm),
225266 by simp [← Set.union_singleton, Ideal.span_union]⟩
226267 clear hI
227- set v : Lex ((Fin (n + 1 ) → ℕ) × ℕ) := toLex
228- (natDegree ∘ e, (Finset.univ.filter (fun i ↦ IsUnit (e i).leadingCoeff)).card) with hv
268+ set v : (Fin (n + 1 ) → WithBot ℕ) ×ₗ Prop := toLex
269+ (degree ∘ e, ¬ ∃ i, IsUnit (e i).leadingCoeff ∧ ∀ j, e j ≠ 0 →
270+ (e i).degree ≤ (e j).degree) with hv
229271 clear_value v
230- have : WellFoundedLT (Lex ((Fin (n + 1 ) → ℕ) × ℕ)) := inferInstance
231- induction v using wellFounded_lt (α := Lex ((Fin (n + 1 ) → ℕ) × ℕ)).induction generalizing R with
272+ induction v using wellFounded_lt (α := (Fin (n + 1 ) → WithBot ℕ) ×ₗ Prop ).induction generalizing R with
232273 | h v H_IH =>
233274 by_cases he0 : e = 0
234275 · rw [he0, Set.range_zero, Ideal.span_singleton_zero]; exact hP₁ R
235276 simp only [funext_iff, Pi.zero_apply, not_forall] at he0
236- obtain ⟨i, hi, H⟩ : ∃ i, e i ≠ 0 ∧ ∀ j, e j ≠ 0 → (e i).natDegree ≤ (e j).natDegree := by
237- have : ∃ n : ℕ, ∃ i, (e i).natDegree = n ∧ (e i) ≠ 0 := by rw [exists_comm]; simpa
238- let m := Nat.find this
239- obtain ⟨i, hi, hi'⟩ : ∃ i, (e i).natDegree = m ∧ (e i) ≠ 0 := Nat.find_spec this
240- exact ⟨i, hi', fun j hj ↦ hi.trans_le (Nat.find_min' _ ⟨j, rfl, hj⟩)⟩
241- by_cases hi' : (e i).Monic; swap
242- · apply hP _ (e i).leadingCoeff
243- · rw [Ideal.map_span, ← Set.range_comp]
277+ by_cases H : ∃ i, IsUnit (e i).leadingCoeff ∧ ∀ j, e j ≠ 0 →
278+ (e i).degree ≤ (e j).degree
279+ · obtain ⟨i, hi, i_min⟩ := H
280+ cases subsingleton_or_nontrivial R
281+ · rw [Subsingleton.elim (Ideal.span (Set.range e)) ⊥]; exact hP₁ R
282+ by_cases H' : ∀ j ≠ i, e j = 0
283+ · convert hP₀ R (((hi.unit ⁻¹ : Rˣ) : R) • e i) ?_ using 1
284+ · refine le_antisymm ?_ ?_ <;>
285+ simp only [Ideal.span_le, Set.range_subset_iff, Set.singleton_subset_iff]
286+ · intro j
287+ by_cases hij : i = j
288+ · simp only [SetLike.mem_coe, Ideal.mem_span_singleton]
289+ use algebraMap _ _ (e i).leadingCoeff
290+ rw [mul_comm, ← Algebra.smul_def, ← mul_smul, IsUnit.mul_val_inv, one_smul, hij]
291+ · rw [H' j (.symm hij)]
292+ exact Ideal.zero_mem _
293+ · rw [Algebra.smul_def]
294+ apply Ideal.mul_mem_left _ _ (Ideal.subset_span (Set.mem_range_self i))
295+ exact Polynomial.monic_unit_leadingCoeff_inv_smul _ _
296+ · cases subsingleton_or_nontrivial R
297+ · rw [Subsingleton.elim (Ideal.span (Set.range e)) ⊥]; exact hP₁ R
298+ simp only [ne_eq, not_forall, Classical.not_imp] at H'
299+ obtain ⟨j, hj, hj'⟩ := H'
300+ replace i_min := i_min j hj'
301+ rw [← Ideal.span_range_update_divByMonic e i j (.symm hj) hi]
244302 refine H_IH _ ?_ _ rfl
245- sorry
246- · sorry
247- by_cases h' : ∃ j ≠ i, (e j) ≠ 0
248- · sorry
249- · sorry
303+ have h_deg : (((hi.unit ⁻¹ : Rˣ) : R) • e i).degree = (e i).degree := by
304+ rw [degree_eq_natDegree (p := e i) (fun e ↦ by simp [e] at hi),
305+ degree_eq_iff_natDegree_eq, Algebra.smul_def, algebraMap_eq,
306+ natDegree_C_mul_eq_of_mul_ne_zero]
307+ · rw [IsUnit.val_inv_mul]; exact one_ne_zero
308+ · exact (Polynomial.monic_unit_leadingCoeff_inv_smul (e i) hi).ne_zero
309+ refine .left _ _ (lt_of_le_of_ne ?_ ?_)
310+ · show _ ≤ (ofLex v).1
311+ intro k
312+ simp only [Function.comp_apply, Function.update_apply, hv, ne_eq, not_exists, not_and,
313+ not_forall, Classical.not_imp, not_le, ofLex_toLex]
314+ split_ifs with hjk
315+ · rw [hjk]
316+ exact (degree_modByMonic_le _
317+ (Polynomial.monic_unit_leadingCoeff_inv_smul _ _)).trans (h_deg.trans_le i_min)
318+ · exact le_rfl
319+ · show _ ≠ (ofLex v).1
320+ simp only [hv, ne_eq, not_exists, not_and, not_forall, not_le, funext_iff,
321+ Function.comp_apply, exists_prop, ofLex_toLex]
322+ use j
323+ simp only [Function.update_same]
324+ exact ((degree_modByMonic_lt _
325+ (Polynomial.monic_unit_leadingCoeff_inv_smul _ _)).trans_le (h_deg.trans_le i_min)).ne
326+ obtain ⟨i, hi, i_min⟩ : ∃ i, e i ≠ 0 ∧ ∀ j, e j ≠ 0 → (e i).degree ≤ (e j).degree := by
327+ have : ∃ n : ℕ, ∃ i, (e i).degree = n ∧ (e i) ≠ 0 := by
328+ obtain ⟨i, hi⟩ := he0; exact ⟨(e i).natDegree, i, degree_eq_natDegree hi, hi⟩
329+ let m := Nat.find this
330+ obtain ⟨i, hi, hi'⟩ : ∃ i, (e i).degree = m ∧ (e i) ≠ 0 := Nat.find_spec this
331+ refine ⟨i, hi', fun j hj ↦ ?_⟩
332+ refine hi.le.trans ?_
333+ rw [degree_eq_natDegree hj, Nat.cast_le]
334+ exact Nat.find_min' _ ⟨j, degree_eq_natDegree hj, hj⟩
335+ have : ¬ IsUnit (e i).leadingCoeff := fun HH ↦ H ⟨i, HH, i_min⟩
336+ apply hP _ (e i).leadingCoeff
337+ · rw [Ideal.map_span, ← Set.range_comp]
338+ refine H_IH _ ?_ _ rfl
339+ rw [hv, Prod.Lex.lt_iff']
340+ constructor
341+ · intro j; simpa using degree_map_le _ _
342+ simp only [coe_mapRingHom, Function.comp_apply, ne_eq, hv, ofLex_toLex,
343+ not_exists, not_and, not_forall, Classical.not_imp, not_le, H, not_false_eq_true]
344+ intro h_eq
345+ rw [lt_iff_le_not_le]
346+ simp only [exists_prop, le_Prop_eq, implies_true, true_implies, not_forall, Classical.not_imp,
347+ not_exists, not_and, not_lt, true_and]
348+ refine ⟨i, ?_, ?_⟩
349+ · replace h_eq := congr_fun h_eq i
350+ simp only [Function.comp_apply] at h_eq
351+ have := IsLocalization.Away.algebraMap_isUnit (S := Localization.Away (e i).leadingCoeff)
352+ (e i).leadingCoeff
353+ convert this
354+ nth_rw 2 [← coeff_natDegree]
355+ rw [natDegree_eq_of_degree_eq h_eq, coeff_map, coeff_natDegree]
356+ · intro j hj
357+ refine le_trans ?_ ((i_min j (fun e ↦ hj (by simp [e]))).trans_eq (congr_fun h_eq j).symm)
358+ simpa using degree_map_le _ _
359+ · rw [Ideal.map_span, ← Set.range_comp]
360+ refine H_IH _ ?_ _ rfl
361+ rw [hv]
362+ refine .left _ _ (lt_of_le_of_ne ?_ ?_)
363+ · intro j; simpa using degree_map_le _ _
364+ simp only [coe_mapRingHom, Function.comp_apply, ne_eq, hv, ofLex_toLex,
365+ not_exists, not_and, not_forall, Classical.not_imp, not_le, H, not_false_eq_true]
366+ intro h_eq
367+ replace h_eq := congr_fun h_eq i
368+ simp only [Ideal.Quotient.algebraMap_eq, Function.comp_apply, degree_map_eq_iff,
369+ Ideal.Quotient.mk_singleton_self, ne_eq, not_true_eq_false, false_or] at h_eq
370+ exact hi h_eq
0 commit comments