1-- Dickson's finite-basis theorem by classical finite-coordinate induction (ZF).2-- Part of Cumulus, the Grace17 mathematics library.3-- Copyright (c) 2026 Grant Passmore.4-- Released under the Apache License 2.0. See LICENSE in the repository root.5-- Authors: Grant Passmore67module Grace.Cumulus.Algebra.Polynomial.Dickson8import Divisibility910predicate MonomialCover (C S B : Set) :=∀ m ∈ S, ∃ b ∈ B, MonomialDivides(C, b, m)11predicate FiniteMonomialBasis (C S B : Set) := Finite(B) ∧ B ⊆ S ∧ MonomialCover(C, S, B)12predicate DicksonOn (V C : Set) :=∀ S, S ⊆ monomials(V) →∃ B, FiniteMonomialBasis(C, S, B)13def exponentSlice (S j n : Set) : Set:= {m ∈ S | m(j) = n}14predicate BoundedMonomialCover (C S j n B : Set) :=∀ m ∈ S, m(j) < n →∃ b ∈ B, MonomialDivides(insert(j, C), b, m)1516theorem exponentSlice.subset (S j n : Set)17shows exponentSlice(S, j, n) ⊆ S18proof19simp2021theorem listExponents.bounded (C i : Set) (xs : List(C))22requires naturals : ∀ m ∈ C, Nat(m(i))23shows∃ n, Nat(n) ∧∀ m ∈ listSupport{C}(xs), m(i) ≤ n24proof25induction xs26| List.nil =>27refine⟨0, Naturals.constructor.zero, _⟩28intros m member29rw listSupport at member30exfalso31exactset.empty with member32| List.cons(x, tail) using ih =>33obtain⟨n, nNat, bounded⟩:= ih34have xNat := naturals with x35have nextNat : Nat(n + x(i)) bytypecheck36refine⟨n + x(i), nextNat, _⟩37intros m member38rw listSupport at member39have alternatives := insert.membership.forward with member40cases alternatives with equal | old41 . rw equal42arith43 . have bound := bounded with m, old44have subset := listSupport.subset with*45have inC := subset with m, old46have mNat := naturals with m, inC47arith4849theorem Finite.exponents_bounded (V S j : Set)50requires finite : Finite(S)51requires subset : S ⊆ monomials(V)52requires index : j ∈ V53shows∃ n, Nat(n) ∧∀ m ∈ S, m(j) ≤ n54proof55obtain⟨xs, list, covered⟩:= Finite.list_cover with finite56have naturals : ∀ m ∈ S, Nat(m(j))57intros m hm58have included := subset59have member := included with m, hm60exact monomials.exponent with*61obtain⟨n, natural, bound⟩:= listExponents.bounded at S, j, xs with*62refine⟨n, natural, _⟩63intros m hm64have member := covered with m, hm65exact bound with m, member6667theorem DicksonOn.empty (V : Set)68shows DicksonOn(V, ∅)69proof70intros S subset71have casesS : (∃ m, m ∈ S) ∨¬(∃ m, m ∈ S) bytauto72cases casesS with inhabited | empty73 . obtain⟨a, member⟩:= inhabited74witness {a}75unfold FiniteMonomialBasis76refine⟨Finite.singleton at a, _, _⟩77intros b hb78have equal := singleton.membership.forward with hb79 rwa equal80intros m hm81refine⟨a, singleton.self at a, _⟩82intros i impossible83exfalso84exactset.empty with impossible85 . witness∅86unfold FiniteMonomialBasis87refine⟨Finite.empty, empty.subset at S, _⟩88intros m hm89have inhabited : ∃ a, a ∈ S byrefine⟨m, hm⟩90exfalso91exact empty with inhabited9293-- At height n, finitely many slices inherit finite bases from C.94theorem DicksonOn.bounded_slices (V C j : Set, n : Nat)95requires index : j ∈ V96requires previous : DicksonOn(V, C)97shows∀ S, S ⊆ monomials(V) →∃ B, Finite(B) ∧ B ⊆ S ∧ BoundedMonomialCover(C, S, j, n, B)98proof99induction n100| zero =>101intros S subset102refine⟨∅, Finite.empty, empty.subset at S, _⟩103intros m hm below104have member := subset with m, hm105have mNat := monomials.exponent at V, m, j with*106have impossible : m(j) < m(j) byarith107exfalso108exact Less.irreflexive with mNat, impossible109| succ(k) using ih =>110intros S subset111obtain⟨B, finiteB, subsetB, coveredB⟩:= ih with S, subset112have sliceSubset := exponentSlice.subset at S, j, k113have sliceBound := Subset.transitive with sliceSubset, subset114have finiteBases := previous115obtain⟨D, basisD⟩:= finiteBases with exponentSlice(S, j, k), sliceBound116rcases basisD with⟨finiteD, subsetD, coveredD⟩117have finite := Finite.union with finiteB, finiteD118have subsetDS := Subset.transitive with subsetD, sliceSubset119have included : B ∪ D ⊆ S bysimp [Subset, union2.membership]120refine⟨B ∪ D, finite, included, _⟩121intros m hm below122have source := subset123have member := source with m, hm124have mNat := monomials.exponent at V, m, j with*125have alternatives : m(j) < k ∨¬(m(j) < k) bytauto126cases alternatives with earlier | last127obtain⟨b, hb, divides⟩:= coveredB with m, hm, earlier128have inUnion : b ∈ B ∪ D129apply union2.membership.backward130left131exact hb132refine⟨b, inUnion, divides⟩133 . have lower := LessEqual.of_not_Less at m(j), k with*134have upper := Less.successor_upper at m(j), k with*135have atLast := LessEqual.antisymmetric at m(j), k with*136have inSlice : m ∈ exponentSlice(S, j, k) := exponentSlice.membership.backward with⟨hm, atLast⟩137obtain⟨d, hd, sliceDivides⟩:= coveredD with m, inSlice138have includedD := subsetD139have bInSlice := includedD with d, hd140have data := exponentSlice.membership.forward with bInSlice141have coordinate : d(j) ≤ m(j)142rw [data.right, atLast]143exact LessEqual.reflexive at k with*144have extended := MonomialDivides.insert with sliceDivides, coordinate145have dInUnion : d ∈ B ∪ D146apply union2.membership.backward147right148exact hd149refine⟨d, dInUnion, extended⟩150151theorem DicksonOn.insert (V C j : Set)152requires index : j ∈ V153requires previous : DicksonOn(V, C)154shows DicksonOn(V, insert(j, C))155proof156intros S subset157have finiteBases := previous158obtain⟨B, basisB⟩:= finiteBases with S, subset159rcases basisB with⟨finiteB, subsetB, coveredB⟩160have boundedB := Subset.transitive with subsetB, subset161obtain⟨n, natural, bound⟩:= Finite.exponents_bounded at V, B, j with*162have slices := DicksonOn.bounded_slices at V, C, j, n with*163obtain⟨D, finiteD, subsetD, coveredD⟩:= slices with S, subset164have finite := Finite.union with finiteB, finiteD165have included : B ∪ D ⊆ S bysimp [Subset, union2.membership]166witness B ∪ D167unfold FiniteMonomialBasis168refine⟨finite, included, _⟩169intros m hm170have source := subset171have member := source with m, hm172have mNat := monomials.exponent at V, m, j with*173have alternatives : n ≤ m(j) ∨¬(n ≤ m(j)) bytauto174cases alternatives with above | below175obtain⟨b, hb, divides⟩:= coveredB with m, hm176have bBound := bound with b, hb177have bSource := subsetB178have inS := bSource with b, hb179have bMember := source with b, inS180have bNat := monomials.exponent at V, b, j with*181have coordinate := LessEqual.transitive at b(j), n, m(j) with*182have extended := MonomialDivides.insert with divides, coordinate183have inUnion : b ∈ B ∪ D184apply union2.membership.backward185left186exact hb187refine⟨b, inUnion, extended⟩188 . have earlier := Less.of_not_LessEqual at n, m(j) with*189obtain⟨d, hd, sliceDivides⟩:= coveredD with m, hm, earlier190have dInUnion : d ∈ B ∪ D191apply union2.membership.backward192right193exact hd194refine⟨d, dInUnion, sliceDivides⟩195196theorem Dickson.list (V : Set) (xs : List(V))197shows DicksonOn(V, listSupport{V}(xs))198proof199induction xs200| List.nil =>201rw listSupport202exact DicksonOn.empty203| List.cons(x, tail) using ih =>204rw listSupport205exact DicksonOn.insert with ih206207theorem Dickson.finite_coordinates (V : Set)208requires finite : Finite(V)209shows DicksonOn(V, V)210proof211obtain⟨xs, list, covers⟩:= Finite.list_cover with finite212have subset := listSupport.subset with list213have equal := Subset.antisymmetric with subset, covers214have noetherian := Dickson.list with list215 rwa equal at noetherian216217theorem Dickson.finite_basis (V S : Set)218requires finite : Finite(V)219requires subset : S ⊆ monomials(V)220shows∃ B, FiniteMonomialBasis(V, S, B)221proof222have noetherian := Dickson.finite_coordinates with finite223exact noetherian with S, subset224225theorem Dickson.finite_factor_basis (V S : Set)226requires variables : Finite(V)227requires subset : S ⊆ monomials(V)228shows∃ B, Finite(B) ∧ B ⊆ S ∧ (∀ m ∈ S, ∃ b ∈ B, ∃ q ∈ monomials(V), monomialProduct(V, b, q) = m)229proof230obtain⟨B, basis⟩:= Dickson.finite_basis with variables, subset231rcases basis with⟨finite, included, covered⟩232refine⟨B, finite, included, _⟩233intros m hm234obtain⟨b, hb, divides⟩:= covered with m, hm235have inS := included with b, hb236have memberB := subset with b, inS237have memberM := subset with m, hm238obtain⟨q, hq, equation⟩:= MonomialDivides.iff_factor.forward at V, b, m with*239refine⟨b, hb, q, hq, equation⟩240