Skip to content

Add MinimalGeneratingSet for magmas#232

Draft
Copilot wants to merge 10 commits intomainfrom
copilot/add-minimal-generating-set
Draft

Add MinimalGeneratingSet for magmas#232
Copilot wants to merge 10 commits intomainfrom
copilot/add-minimal-generating-set

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 5, 2026

Implements MinimalGeneratingSet function to compute the smallest generating set for magmas, where a generating set S satisfies M = ⟨S⟩ under the magma operation.

Changes

  • MinimalGeneratingSet(M): Returns the smallest subset of GeneratorsOfMagma(M) that generates the full magma M by:
    1. Enumerating subsets of generators in order of increasing size
    2. Returning the first subset that generates the full magma

Usage

gap> M := SmallAntimagma(2, 1);
<magma with 2 generators>

gap> mingens := MinimalGeneratingSet(M);
[ m1 ]

gap> Size(Submagma(M, mingens)) = Size(M);  # Verify closure
true

For a non-minimal generating set, users can directly use GAP's built-in GeneratorsOfMagma(M) function.

Tests

  • Verifies that all antimagmas of order 2 and 3 are generated by one element
  • Verifies that antimagma [4,1] is generated by two elements
  • Validates that minimal generating sets correctly generate all antimagmas of size 2..4

Notes

MinimalGeneratingSet has O(2^g) complexity where g is the number of generators (typically small), making it efficient for most practical cases.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature Request]: MinimalGeneratingSet and GeneratingSet</issue_title>
<issue_description>### Is your feature request related to a problem? Please describe.

MinimalGeneratingSet and GeneratingSet.

Describe the solution you'd like

MinimalGeneratingSet is the smallest subset of $S \subseteq M$ such that $M = \langle S \rangle$

Describe alternatives you've considered

No response

Additional context

No response

Priority

None

Impact

No response

Resources

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits February 5, 2026 21:33
Co-authored-by: limakzi <50334623+limakzi@users.noreply.github.com>
Co-authored-by: limakzi <50334623+limakzi@users.noreply.github.com>
Co-authored-by: limakzi <50334623+limakzi@users.noreply.github.com>
Co-authored-by: limakzi <50334623+limakzi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add MinimalGeneratingSet feature implementation Add GeneratingSet and MinimalGeneratingSet for magmas Feb 5, 2026
Copilot AI requested a review from limakzi February 5, 2026 21:37
Comment thread lib/properties.gi Outdated
return DigraphByEdges(List([1 .. Size(M)], m -> [m, DiagonalOfMultiplicationTable(M)[m]]));
end);

InstallMethod(GeneratingSet, "for a magma", [IsMagma],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot Remove this function completely.
It can be replaced by GeneratorsOfMagma.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the GeneratingSet function completely. Users can use GAP's built-in GeneratorsOfMagma(M) instead. (efa856f)

Comment thread lib/properties.gi
return GeneratorsOfMagma(M);
end);

InstallMethod(MinimalGeneratingSet, "for a magma", [IsMagma],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot Simplify this function. Find the smallest subset of GeneratorsOfMagma that generate magma $M$.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Simplified the function to only search among subsets of GeneratorsOfMagma(M). The algorithm now tries all subsets of generators in order of increasing size and returns the first one that generates the full magma. This is much more efficient. (4567073)

Co-authored-by: limakzi <50334623+limakzi@users.noreply.github.com>
Copilot AI changed the title Add GeneratingSet and MinimalGeneratingSet for magmas Add MinimalGeneratingSet for magmas Feb 5, 2026
Copilot AI requested a review from limakzi February 5, 2026 22:04
Copilot AI and others added 3 commits February 5, 2026 22:05
…subsets

Co-authored-by: limakzi <50334623+limakzi@users.noreply.github.com>
Co-authored-by: limakzi <50334623+limakzi@users.noreply.github.com>
Co-authored-by: limakzi <50334623+limakzi@users.noreply.github.com>
Comment thread tst/test_generating_set.tst Outdated
Comment on lines +23 to +29
# Test all antimagmas of size 2
gap> ForAll(AllSmallAntimagmas(2), M -> Size(Submagma(M, MinimalGeneratingSet(M))) = Size(M));
true

# Test all antimagmas of size 3
gap> ForAll(AllSmallAntimagmas(3), M -> Size(Submagma(M, MinimalGeneratingSet(M))) = Size(M));
true
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot Consolidate these tests for $n$ in range ${2..4}$.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Consolidated tests to cover range [2..4] in a single ForAll test. (5c2c013)

Comment thread lib/properties.gd
Comment on lines +413 to +418
#! @BeginExampleSession
#! gap> M := SmallAntimagma(2, 1);
#! <magma with 2 generators>
#! gap> MinimalGeneratingSet(M);
#! [ m1, m2 ]
#! @EndExampleSession
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot That's not true.
SmallAntimagma(2,1) is cyclic and generated by one element.

Add this as a test for tests that each magma of order $2$ and $3$ is generated by one element. More-over. Add test that antimagma $[4,1]$ is generated by two elements.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed the example to show [ m1 ] instead of [ m1, m2 ]. Added tests verifying that all antimagmas of order 2 and 3 are generated by one element, and that antimagma [4,1] is generated by two elements. (5c2c013)

Comment thread lib/properties.gi Outdated

# This point should never be reached since the full set of generators
# should always generate the magma
Error("MinimalGeneratingSet: Internal error - generators do not generate the magma. This should never happen.");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot Its impossible. Remove this part of code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the unreachable error handling code. (5c2c013)

…chable error

Co-authored-by: limakzi <50334623+limakzi@users.noreply.github.com>
Copilot AI requested a review from limakzi February 5, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: MinimalGeneratingSet and GeneratingSet

2 participants