/-Copyright (c) 2026 Carles Marín. All rights reserved.Released under Apache 2.0 license as described in the file LICENSE.Authors: Carles Marín-/module public import Mathlib.SetTheory.Ordinal.Arithmeticpublic import Mathlib.Data.Multiset.DershowitzMannapublic import Mathlib.Algebra.Ring.Pointwise.Setpublic import Mathlib.Algebra.BigOperators.Group.Multiset.Defspublic import Mathlib.Algebra.BigOperators.Group.List.Defs /-!# The Dubrovin–Gräter–Hanke stratification The stratification `D : Ordinal → Set R` of a ring `R` generated by `M ⊆ R`, defined bywell-founded recursion on ordinals. The minimal multiset of indices in cases 1–2 is chosen with`WellFounded.min` for Mathlib's Dershowitz–Manna order (`Multiset.wellFounded_isDershowitzMannaLT`). ## Main results * `D_zero`, `D_one`, `D_succ`, `D_limit`: the unfolding equations.* `D_succ_case1` … `D_succ_case4`: the four successor cases with their minimality specification.* `D_mono`; `D_ssubset_case1`, `D_ssubset_case2`, `D_ssubset_case3`: monotonicity and strict growth. ## References * F. Jakobs, PhD thesis, 2019, Def. 1.1.4.* N. Dubrovin, J. Gräter, T. Hanke.-/ @[expose] public section open Pointwise Order namespace DGH noncomputable sectionopen Classical variable {R : Type} [Ring R] lemma ord_succ_zero : succ (0 : Ordinal.{0}) = 1 := by rw [succ_eq_add_one, zero_add] lemma ord_succ_ne_zero (a : Ordinal.{0}) : succ a ≠ 0 := by rw [succ_eq_add_one]; exact (add_pos_of_right zero_lt_one a).ne' /-- `D_{α₁} + ⋯ + D_{αₙ}` for the multiset `{α₁,…,αₙ}`. -/def sumSets (E : Ordinal.{0} → Set R) (s : Multiset Ordinal.{0}) : Set R := (s.map E).sum /-- `⋃` over all orderings `l` of the multiset `s` of `D_{l₁} ⋯ D_{lₙ}`. -/def prodSets (E : Ordinal.{0} → Set R) (s : Multiset Ordinal.{0}) : Set R := ⋃ (l : List Ordinal.{0}) (_ : (l : Multiset Ordinal.{0}) = s), (l.map E).prod /-- Inverses of the units of `R` lying in `S`. -/def invSet (S : Set R) : Set R := {x | ∃ u : Rˣ, (u : R) ∈ S ∧ x = ((u⁻¹ : Rˣ) : R)} def SumClosed (S : Set R) : Prop := S + S ⊆ Sdef MulClosed (S : Set R) : Prop := S * S ⊆ S/-- "rationally closed": contains the inverse of each unit of `R` it contains. -/def InvClosed (S : Set R) : Prop := invSet S ⊆ S /-- Candidates for case 1. -/def sumCand (E : Ordinal.{0} → Set R) (a : Ordinal.{0}) : Set (Multiset Ordinal.{0}) := {s | s ≠ 0 ∧ (∀ x ∈ s, x ≤ a) ∧ ¬ sumSets E s ⊆ E a} /-- Candidates for case 2. -/def prodCand (E : Ordinal.{0} → Set R) (a : Ordinal.{0}) : Set (Multiset Ordinal.{0}) := {s | s ≠ 0 ∧ (∀ x ∈ s, x ≤ a) ∧ ¬ prodSets E s ⊆ E a} /-- Candidates for case 3. -/def invCand (E : Ordinal.{0} → Set R) (a : Ordinal.{0}) : Set Ordinal.{0} := {b | b ≤ a ∧ ¬ invSet (E b) ⊆ E a} lemma sumSets_pair (E : Ordinal.{0} → Set R) (a : Ordinal.{0}) : sumSets E {a, a} = E a + E a := by simp [sumSets] lemma prodSets_pair (E : Ordinal.{0} → Set R) (a : Ordinal.{0}) : E a * E a ⊆ prodSets E {a, a} := by intro x hx refine Set.mem_iUnion₂.2 ⟨[a, a], rfl, ?_⟩ simpa using hx lemma sumCand_nonempty {E : Ordinal.{0} → Set R} {a : Ordinal.{0}} (h : ¬ SumClosed (E a)) : (sumCand E a).Nonempty := ⟨{a, a}, by simp, by simp, by rw [sumSets_pair]; exact h⟩ lemma prodCand_nonempty {E : Ordinal.{0} → Set R} {a : Ordinal.{0}} (h : ¬ MulClosed (E a)) : (prodCand E a).Nonempty := ⟨{a, a}, by simp, by simp, fun h' => h ((prodSets_pair E a).trans h')⟩ lemma invCand_nonempty {E : Ordinal.{0} → Set R} {a : Ordinal.{0}} (h : ¬ InvClosed (E a)) : (invCand E a).Nonempty := ⟨a, le_rfl, h⟩ /-- Successor step on an arbitrary family `E` (raw form). -/def succStep₀ (E : Ordinal.{0} → Set R) (a : Ordinal.{0}) : Set R := if h1 : ¬ SumClosed (E a) then E a ∪ sumSets E (Multiset.wellFounded_isDershowitzMannaLT.min _ (sumCand_nonempty h1)) else if h2 : ¬ MulClosed (E a) then E a ∪ prodSets E (Multiset.wellFounded_isDershowitzMannaLT.min _ (prodCand_nonempty h2)) else if h3 : ¬ InvClosed (E a) then E a ∪ invSet (E (wellFounded_lt.min _ (invCand_nonempty h3))) else E a /-- Restriction of a family to indices `≤ a`. -/def restr (E : Ordinal.{0} → Set R) (a : Ordinal.{0}) : Ordinal.{0} → Set R := fun b => if b ≤ a then E b else ∅ /-- Successor step: only looks at `E b` for `b ≤ a`. -/def succStep (E : Ordinal.{0} → Set R) (a : Ordinal.{0}) : Set R := succStep₀ (restr E a) a lemma succStep_congr {E F : Ordinal.{0} → Set R} {a : Ordinal.{0}} (h : ∀ b ≤ a, E b = F b) : succStep E a = succStep F a := by unfold succStep congr 1 funext b unfold restr split_ifs with hb · exact h b hb · rfl variable (M : Set R) /-- `D_1 = {0, 1, -1} ∪ M ∪ -M`. -/def layer1 : Set R := {0, 1, -1} ∪ M ∪ -M /-- One step of the recursion, given the family `E` of earlier strata. -/def core (α : Ordinal.{0}) (E : Ordinal.{0} → Set R) : Set R := if α = 0 then {0} else if h : ∃ a, α = succ a then (if h.choose = 0 then layer1 M else succStep E h.choose) else ⋃ (b) (_ : b < α), E b /-- The DGH stratification. -/def D : Ordinal.{0} → Set R := wellFounded_lt.fix (fun α IH => core M α (fun b => if h : b < α then IH b h else ∅)) lemma D_eq (α : Ordinal.{0}) : D M α = core M α (fun b => if b < α then D M b else ∅) := by rw [D, WellFounded.fix_eq] rfl /-! ### Unfolding equations -/ theorem D_zero : D M 0 = {0} := by rw [D_eq]; simp [core] theorem D_one : D M 1 = layer1 M := by rw [D_eq] have h1 : (1 : Ordinal.{0}) ≠ 0 := one_ne_zero have hex : ∃ a, (1 : Ordinal.{0}) = succ a := ⟨0, ord_succ_zero.symm⟩ have hc : hex.choose = 0 := succ_injective (hex.choose_spec.symm.trans ord_succ_zero.symm) simp only [core, h1, ite_false, dite_eq_left hex, hc, ite_true] theorem D_succ {a : Ordinal.{0}} (ha : a ≠ 0) : D M (succ a) = succStep (D M) a := by rw [D_eq] have hex : ∃ b, succ a = succ b := ⟨a, rfl⟩ have hc : hex.choose = a := (succ_injective hex.choose_spec).symm simp only [core, ord_succ_ne_zero, ite_false, dite_eq_left hex, hc, ha] apply succStep_congr intro b hb show (if b < succ a then D M b else ∅) = D M b rw [ite_eq_left (lt_succ_iff.2 hb)] theorem D_limit {α : Ordinal.{0}} (h0 : α ≠ 0) (hs : ¬ ∃ a, α = succ a) : D M α = ⋃ (b) (_ : b < α), D M b := by rw [D_eq] simp only [core, h0, ite_false, dite_eq_right hs] ext x simp +contextual [Set.mem_iUnion] /-! ### The four successor cases (for `a ≠ 0`) -/ omit [Ring R] inlemma restr_self (E : Ordinal.{0} → Set R) (a : Ordinal.{0}) : restr E a a = E a := by simp [restr] lemma sumSets_restr {E : Ordinal.{0} → Set R} {a : Ordinal.{0}} {s : Multiset Ordinal.{0}} (hs : ∀ x ∈ s, x ≤ a) : sumSets (restr E a) s = sumSets E s := by unfold sumSets congr 1 exact Multiset.map_congr rfl fun x hx => by simp [restr, hs x hx] lemma prodSets_restr {E : Ordinal.{0} → Set R} {a : Ordinal.{0}} {s : Multiset Ordinal.{0}} (hs : ∀ x ∈ s, x ≤ a) : prodSets (restr E a) s = prodSets E s := by unfold prodSets refine Set.iUnion_congr fun l => Set.iUnion_congr fun hl => ?_ congr 1 refine List.map_congr_left fun x hx => ?_ have : x ∈ s := by rw [← hl]; exact Multiset.mem_coe.2 hx simp [restr, hs x this] lemma sumCand_restr (E : Ordinal.{0} → Set R) (a : Ordinal.{0}) : sumCand (restr E a) a = sumCand E a := by ext s simp only [sumCand, Set.mem_ofPred_eq, restr_self] constructor · rintro ⟨h0, hs, h⟩; exact ⟨h0, hs, by rwa [sumSets_restr hs] at h⟩ · rintro ⟨h0, hs, h⟩; exact ⟨h0, hs, by rwa [sumSets_restr hs]⟩ lemma prodCand_restr (E : Ordinal.{0} → Set R) (a : Ordinal.{0}) : prodCand (restr E a) a = prodCand E a := by ext s simp only [prodCand, Set.mem_ofPred_eq, restr_self] constructor · rintro ⟨h0, hs, h⟩; exact ⟨h0, hs, by rwa [prodSets_restr hs] at h⟩ · rintro ⟨h0, hs, h⟩; exact ⟨h0, hs, by rwa [prodSets_restr hs]⟩ lemma invCand_restr (E : Ordinal.{0} → Set R) (a : Ordinal.{0}) : invCand (restr E a) a = invCand E a := by ext b simp only [invCand, Set.mem_ofPred_eq, restr_self] constructor · rintro ⟨hb, h⟩; exact ⟨hb, by simpa [restr, hb] using h⟩ · rintro ⟨hb, h⟩; exact ⟨hb, by simpa [restr, hb] using h⟩ /-- Case 1: `D a` not closed under sums. -/theorem D_succ_case1 {a : Ordinal.{0}} (ha : a ≠ 0) (h1 : ¬ SumClosed (D M a)) : ∃ s ∈ sumCand (D M) a, (∀ t ∈ sumCand (D M) a, ¬ Multiset.IsDershowitzMannaLT t s) ∧ D M (succ a) = D M a ∪ sumSets (D M) s := by have h1' : ¬ SumClosed (restr (D M) a a) := by rwa [restr_self] set s := Multiset.wellFounded_isDershowitzMannaLT.min _ (sumCand_nonempty h1') with hsdef have hs : s ∈ sumCand (restr (D M) a) a := WellFounded.min_mem _ _ _ refine ⟨s, by rwa [sumCand_restr] at hs, fun t ht => ?_, ?_⟩ · exact WellFounded.not_lt_min Multiset.wellFounded_isDershowitzMannaLT _ (show t ∈ sumCand (restr (D M) a) a by rwa [sumCand_restr]) · rw [D_succ M ha, succStep, succStep₀, dite_eq_left h1', ← hsdef, restr_self, sumSets_restr hs.2.1] /-- Case 2: `D a` closed under sums, not under products. -/theorem D_succ_case2 {a : Ordinal.{0}} (ha : a ≠ 0) (h1 : SumClosed (D M a)) (h2 : ¬ MulClosed (D M a)) : ∃ s ∈ prodCand (D M) a, (∀ t ∈ prodCand (D M) a, ¬ Multiset.IsDershowitzMannaLT t s) ∧ D M (succ a) = D M a ∪ prodSets (D M) s := by have h1' : ¬ ¬ SumClosed (restr (D M) a a) := by rw [restr_self]; exact not_not.2 h1 have h2' : ¬ MulClosed (restr (D M) a a) := by rwa [restr_self] set s := Multiset.wellFounded_isDershowitzMannaLT.min _ (prodCand_nonempty h2') with hsdef have hs : s ∈ prodCand (restr (D M) a) a := WellFounded.min_mem _ _ _ refine ⟨s, by rwa [prodCand_restr] at hs, fun t ht => ?_, ?_⟩ · exact WellFounded.not_lt_min Multiset.wellFounded_isDershowitzMannaLT _ (show t ∈ prodCand (restr (D M) a) a by rwa [prodCand_restr]) · rw [D_succ M ha, succStep, succStep₀, dite_eq_right h1', dite_eq_left h2', ← hsdef, restr_self, prodSets_restr hs.2.1] /-- Case 3: `D a` closed under sums and products, not rationally closed. -/theorem D_succ_case3 {a : Ordinal.{0}} (ha : a ≠ 0) (h1 : SumClosed (D M a)) (h2 : MulClosed (D M a)) (h3 : ¬ InvClosed (D M a)) : ∃ b ∈ invCand (D M) a, (∀ c ∈ invCand (D M) a, ¬ c < b) ∧ D M (succ a) = D M a ∪ invSet (D M b) := by have h1' : ¬ ¬ SumClosed (restr (D M) a a) := by rw [restr_self]; exact not_not.2 h1 have h2' : ¬ ¬ MulClosed (restr (D M) a a) := by rw [restr_self]; exact not_not.2 h2 have h3' : ¬ InvClosed (restr (D M) a a) := by rwa [restr_self] set b := (wellFounded_lt (α := Ordinal.{0})).min _ (invCand_nonempty h3') with hbdef have hb : b ∈ invCand (restr (D M) a) a := WellFounded.min_mem _ _ _ refine ⟨b, by rwa [invCand_restr] at hb, fun c hc => ?_, ?_⟩ · exact WellFounded.not_lt_min (wellFounded_lt (α := Ordinal.{0})) _ (show c ∈ invCand (restr (D M) a) a by rwa [invCand_restr]) · rw [D_succ M ha, succStep, succStep₀, dite_eq_right h1', dite_eq_right h2', dite_eq_left h3', ← hbdef, restr_self] simp [restr, hb.1] /-- Case 4: otherwise the stratum does not grow. -/theorem D_succ_case4 {a : Ordinal.{0}} (ha : a ≠ 0) (h1 : SumClosed (D M a)) (h2 : MulClosed (D M a)) (h3 : InvClosed (D M a)) : D M (succ a) = D M a := by have h1' : ¬ ¬ SumClosed (restr (D M) a a) := by rw [restr_self]; exact not_not.2 h1 have h2' : ¬ ¬ MulClosed (restr (D M) a a) := by rw [restr_self]; exact not_not.2 h2 have h3' : ¬ ¬ InvClosed (restr (D M) a a) := by rw [restr_self]; exact not_not.2 h3 rw [D_succ M ha, succStep, succStep₀, dite_eq_right h1', dite_eq_right h2', dite_eq_right h3', restr_self] /-! ### Monotonicity -/ theorem D_subset_succ (a : Ordinal.{0}) : D M a ⊆ D M (succ a) := by rcases eq_or_ne a 0 with rfl | ha · rw [D_zero, ord_succ_zero, D_one] intro x hx rw [Set.mem_singleton_iff] at hx subst hx simp [layer1] · rw [D_succ M ha, succStep] have key : restr (D M) a a ⊆ succStep₀ (restr (D M) a) a := by unfold succStep₀ split_ifs <;> first | exact Set.subset_union_left | exact le_rfl exact (restr_self (D M) a).symm.subset.trans key theorem D_mono {b α : Ordinal.{0}} (h : b ≤ α) : D M b ⊆ D M α := by revert b refine WellFoundedLT.induction (motive := fun α => ∀ {b}, b ≤ α → D M b ⊆ D M α) α ?_ intro α IH b h rcases h.eq_or_lt with rfl | hlt · exact le_rfl · by_cases hs : ∃ a, α = succ a · obtain ⟨a, rfl⟩ := hs exact (IH a (lt_succ a) (lt_succ_iff.1 hlt)).trans (D_subset_succ M a) · have h0 : α ≠ 0 := by rintro rfl; exact not_lt_zero hlt rw [D_limit M h0 hs] exact Set.subset_iUnion₂ (s := fun c (_ : c < α) => D M c) b hlt /-! ### Strict growth -/ theorem D_ssubset_case1 {a : Ordinal.{0}} (h1 : ¬ SumClosed (D M a)) : D M a ⊂ D M (succ a) := by rcases eq_or_ne a 0 with rfl | ha · exfalso; apply h1 rw [D_zero, SumClosed]; simp · obtain ⟨s, hs, -, he⟩ := D_succ_case1 M ha h1 rw [he] exact ssubset_of_subset_not_subset Set.subset_union_left fun h => hs.2.2 (Set.subset_union_right.trans h) theorem D_ssubset_case2 {a : Ordinal.{0}} (h1 : SumClosed (D M a)) (h2 : ¬ MulClosed (D M a)) : D M a ⊂ D M (succ a) := by rcases eq_or_ne a 0 with rfl | ha · exfalso; apply h2 rw [D_zero, MulClosed]; simp · obtain ⟨s, hs, -, he⟩ := D_succ_case2 M ha h1 h2 rw [he] exact ssubset_of_subset_not_subset Set.subset_union_left fun h => hs.2.2 (Set.subset_union_right.trans h) theorem D_ssubset_case3 {a : Ordinal.{0}} (h1 : SumClosed (D M a)) (h2 : MulClosed (D M a)) (h3 : ¬ InvClosed (D M a)) : D M a ⊂ D M (succ a) := by rcases eq_or_ne a 0 with rfl | ha · exfalso; apply h3 rw [D_zero, InvClosed] rintro x ⟨u, hu, rfl⟩ rw [Set.mem_singleton_iff] at hu ⊢ -- a unit equal to 0 forces the zero ring have h01 : (0 : R) = 1 := by have := u.mul_inv; rw [hu, zero_mul] at this; exact this have := subsingleton_of_zero_eq_one h01 exact Subsingleton.elim _ _ · obtain ⟨b, hb, -, he⟩ := D_succ_case3 M ha h1 h2 h3 rw [he] exact ssubset_of_subset_not_subset Set.subset_union_left fun h => hb.2 (Set.subset_union_right.trans h) end end DGH