Skip to content
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e2e4fba
Added the Subring package
fragandi Apr 17, 2025
f1f3aa0
typos handled. Still need to resolve the issue with directory structure
fragandi Apr 18, 2025
2564a4a
Merge branch 'development' into master
fragandi Apr 18, 2025
2b35a8a
directory structure is fixed
fragandi Apr 18, 2025
c5e7721
paths fixed
fragandi Apr 18, 2025
ce9c38d
renamed package Subring -> Subrings
mahrud May 25, 2025
c81444a
deleted .vscode/settings.json
mahrud May 25, 2025
c6774f2
added link to SubalgebraBases in Subrings
mahrud May 25, 2025
308d007
fixed auxiliary file paths in Subrings
mahrud May 25, 2025
98da806
set AuxiliaryFiles for Subrings
mahrud Jun 2, 2025
b38618a
Merge branch 'Macaulay2:stable' into master
fragandi Jun 12, 2026
6d807f5
Add workflow to build and push testbot Docker image
d-torrance Jun 14, 2026
1a37f6f
Trust the Macaulay2 Homebrew tap
d-torrance Jun 6, 2026
fdf5ff2
Merge branch 'Macaulay2:stable' into master
ollieclarke8787 Jul 3, 2026
287c51b
cache subring in matrix
ollieclarke8787 Jul 3, 2026
79bc995
update Subring to handle towers of rings
ollieclarke8787 Jul 3, 2026
c9bb90c
fix M -> genMatrix
ollieclarke8787 Jul 3, 2026
9785924
fix subring opts
ollieclarke8787 Jul 3, 2026
0dd0ba9
add options for subring(List)
ollieclarke8787 Jul 3, 2026
7332fd8
fix isSubringElement to work with towers of rings
ollieclarke8787 Jul 3, 2026
6624403
fix indentation
ollieclarke8787 Jul 3, 2026
149d940
clean up comment
ollieclarke8787 Jul 3, 2026
89210ef
add test for tower of rings
ollieclarke8787 Jul 3, 2026
69c567b
TODO: rewrite isSubringElement to use hooks for future-proofing
ollieclarke8787 Jul 3, 2026
2f4dcb4
export Subring type
ollieclarke8787 Jul 4, 2026
b4777fe
add flattenRing Subring
ollieclarke8787 Jul 5, 2026
7b061ac
clean Subring doc
ollieclarke8787 Jul 5, 2026
ce6a670
clean spacing
ollieclarke8787 Jul 5, 2026
27ee670
use hooks for subring membership
ollieclarke8787 Jul 5, 2026
67170be
fix doc for flattenedRing
ollieclarke8787 Jul 5, 2026
2c5af3e
add flattenedRing doc
ollieclarke8787 Jul 5, 2026
1492759
add tests
ollieclarke8787 Jul 5, 2026
571b39c
use Subring in SubalgebraBases
ollieclarke8787 Jul 7, 2026
7b8351d
Update M2/Macaulay2/packages/Subrings.m2
ollieclarke8787 Aug 12, 2026
6b67548
Update package headline
ollieclarke8787 Aug 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/docker-testbot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This workflow builds the Macaulay2 testbot Docker image from
# M2/BUILD/docker/testbot/Dockerfile and pushes it to GitHub Packages,
# tagged with the current Macaulay2 version (see M2/VERSION) and "latest".
#
# The resulting image is published at
# https://github.com/Macaulay2/M2/pkgs/container/testbot

name: Build and push testbot Docker image

on: workflow_dispatch

env:
IMAGE_NAME: ghcr.io/macaulay2/testbot

jobs:
docker-testbot:
runs-on: ubuntu-latest
permissions:
packages: write

steps:
- uses: actions/checkout@v6

- name: Determine image tags
run: |
M2_VERSION=$(cat M2/VERSION)
echo "M2_VERSION=$M2_VERSION" >> "$GITHUB_ENV"

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image
uses: docker/build-push-action@v6
with:
context: M2/BUILD/docker/testbot
push: true
tags: |
${{ env.IMAGE_NAME }}:v${{ env.M2_VERSION }}
${{ env.IMAGE_NAME }}:latest
1 change: 1 addition & 0 deletions .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
run: |
brew config
brew update
brew trust macaulay2/tap
brew tap macaulay2/tap
brew install automake bison boost libtool tbb ccache ctags llvm make yasm libffi msolve googletest fplll eigen jansson r palp
brew install texinfo || true # sometimes post-install step fails
Expand Down
1 change: 1 addition & 0 deletions M2/Macaulay2/packages/=distributed-packages
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ SpecialFanoFourfolds
RationalPoints2
SuperLinearAlgebra
SubalgebraBases
Subrings
AInfinity
LinearTruncations
ThinSincereQuivers
Expand Down
205 changes: 205 additions & 0 deletions M2/Macaulay2/packages/Subrings.m2
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
-- -*- coding: utf-8 -*-
newPackage(
"Subrings",
Version => "1.1",
Date => "July 3, 2026",
Authors => {
{Name => "Francesca Gandini", Email => "fra.gandi.phd@gmail.com"},
{Name => "Casey Hill", Email => "casey.hill@uky.edu"},
{Name => "Trevor K. Karn", Email => "karnx018@umn.edu"},
{Name => "Miranda Moore", Email => "moor2340@umn.edu"},
{Name => "Christopher O'Neill", Email => "cdoneill@sdsu.edu"},
{Name => "Oliver Clarke", Email => "oliver.clarke@durham.ac.uk"}
},

Headline => "a package for subrings",
Comment thread
d-torrance marked this conversation as resolved.
Outdated
Keywords => {"Commutative Algebra"},
AuxiliaryFiles => true,
DebuggingMode => true
Comment thread
ollieclarke8787 marked this conversation as resolved.
Outdated
)


export {"subring",
"subringGenerators",
"presentationRing",
"presentationMap",
"presentationIdeal",
"toQuotientRing",
"isSubringElement",
"GeneratorSymbol",
"flattenedRing",
"Subring",
}

Subring = new Type of HashTable

-- a method to create subrings from a `Matrix` of generators
subring = method(
Options => {GeneratorSymbol=>null}
)
subring Matrix := opts -> genMatrix -> (
if genMatrix.cache#?Subring then return genMatrix.cache#Subring;
-- compute presentation ring
R := ring genMatrix;
-- deal with towers of rings
(F,RtoF,FtoR) := flattenRing(R,Result=>3);
coeffRing := coefficientRing F;
local subductionRing;
if instance(opts.GeneratorSymbol,Nothing) then
subductionRing = coeffRing(monoid[Variables => numcols genMatrix])
else if instance(opts.GeneratorSymbol,Symbol) then
subductionRing = coeffRing[opts.GeneratorSymbol_1..opts.GeneratorSymbol_(numcols genMatrix)]
else error("Invalid GeneratorSymbol option");
presentationMap := map(R,subductionRing,genMatrix);
S := new Subring from {
"ambientRing" => R,
"flattenedRing" => F,
"generators" => RtoF genMatrix,
"originalGenerators" => genMatrix,
"presentationRing" => subductionRing,
"presentationMap" => presentationMap,
"flatteningMap" => RtoF,
"inverseFlatteningMap" => FtoR,
cache => new CacheTable from {}
};
genMatrix.cache#Subring = S
)

-- a method to create subrings from a `List` of generators
subring List := opts -> genList -> (
subring(matrix {genList}, opts)
)

flattenedRing = method()
flattenedRing Subring := S -> S#"flattenedRing"
Comment on lines +71 to +72

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just install a method flattenRing Subring?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flattenedRing was defined in SubalgebraBases so I pulled it across to Subrings, it should be possible to swap over to using flattenRing but the underlying meaning seems a little different: the flattenedRing S of S:Subring is equivalent to flattenRing ambient S. For now I've added flattenRing in b4777fe


presentationRing = method()
presentationRing Subring := S -> (
S#"presentationRing"
)

presentationMap = method()
presentationMap Subring := S -> (
S#"presentationMap"
)

presentationIdeal = method()
presentationIdeal Subring := S -> (
f := presentationMap S;
return ker f; --kernel is cached automatically
)

-- a quotient ring isomorphic to the image of the subring inside of the presentation ring
toQuotientRing = method()
toQuotientRing Subring := S -> (
P := presentationRing S;
I := presentationIdeal S;
return P/I;
)

subringGenerators = method() -- gens that live in flattened ring
subringGenerators Subring := S -> S#"generators"

generators Subring := Matrix => opts -> S -> ( -- gens that live in ambient ring
S#"originalGenerators"
)

ambient Subring := S -> S#"ambientRing"

numgens Subring := S -> numcols gens S

-- format printing of Subring type
net Subring := S -> (
R := ambient S;
P := presentationRing S;
g := flatten entries gens S;
genstr := "";
if #g <= 3 then (
genstr = toString(g_{0 .. min(2, #g-1)});
) else (
genstr = "{" | toString(g_0) | ", " | toString(g_1) | ", " | toString(g_2) | ", ...}";
);

"Subring of " | toString(R) | " generated by " | genstr | " with presentation ring " | toString(P)
)

-*
TODO:
-- use hooks, see:
-- help "using hooks"
-- to dynamically dispatch the task of computing the subring membership
-- this will allow other packages to provide more efficient algorithms later
-- For example, the SublagebraBases package can 'addHook' some function that
-- checks if there is a SAGBI basis, and if there is, uses subduction to check membership
*-


-- given a subring S and an element x of the ambient ring, checks whether x is in S
isSubringElement = method()
isSubringElement(RingElement, Subring) := (r, S) -> (
if not S.cache#?"tensorGraphIdeal" and not S.cache#?"ambientToTensor" then (
R := ambient S;
F := flattenedRing S;
P := presentationRing S;
T := tensor(F, P, MonomialOrder=>Eliminate(numgens F));
gT := vars T;
F2T := map(T, F, gT_{0 .. numgens F - 1});
R2T := F2T * (S#"flatteningMap");
P2T := map(T, P, gT_{numgens F .. numgens T - 1});
subringGens := subringGenerators S;
presGens := matrix {gens P};
graphIdealGens := P2T(presGens) - F2T(subringGens);
I := ideal graphIdealGens;
S.cache#"tensorGraphIdeal"=I;
S.cache#"ambientToTensor"=R2T;
);
M := matrix {{S.cache#"ambientToTensor"(r) % S.cache#"tensorGraphIdeal"}};
selectInSubring(1, M) == M
)

-- equality of Subrings
-- check that every generator of S1 is in S2 and every generator of S2 is in S1
Subring == Subring := (S1, S2) -> (
if not (ambient S1) === (ambient S2) then return false;
all(entries(subringGenerators S1)_0, f -> isSubringElement(f, S2)) and all(entries(subringGenerators S2)_0, f -> isSubringElement(f, S1))
)


-----------------------------------------
--- Load documentation and test files ---
-----------------------------------------
beginDocumentation()

load "./Subrings/SubringDoc.m2"
load "./Subrings/SubringTests.m2"

end--

restart
installPackage "Subrings"
R = QQ[x]
S1 = subring {x, x^2}
S2 = subring {x^2}
S3 = subring {x}
S1 == S3 --true
S1 == S2 --false

net S3

mingens S1
presentationRing S1
mingens

gens S1

-- run tests
check Subring



R = QQ[x][y]
S = subring {x+y, x*y}
r = x^4 + y^4
isSubringElement(r, S)
isSubringElement(r + x, S)
isSubringElement(r + x*y, S)
Loading
Loading