I am trying to write a program which, given a multiplication table of a finite magma $(G, *)$, should produce at least one (or all possible) generating subset $S$ of minimal cardinality.
More precisely $S \subset G, \ |G| = n \in \mathbb{N}$. Let $<S>$ be operational closure of $S$ in $G$. I am interested in outputting at least one $S$, such that $<S> = G$ and for every $S'$ with that property $|S| \le |S'|$.
So far I have tried to understand what is $<a>, a \in G$, but due to lack of even simple associativity this is non-trivial. I defined right-associative power operation $a^k := (k = 1) \ ?\ a \ :\ a * a^{k-1}$, for $k \ge 1$. I already know how to list the elements of a set $R_a := \{a^k \ |\ k \ge 1\}$, and of similarly defined set $L_a$, if $a^k$ is defined as left-associative. These are, in general case, proper subsets of $<a>$, and need not even be closed under multiplication (I have constructed counterexamples).
All in all, proper description of $<a>$ still evades me, but even then, I would have to figure out how to describe $<a_1,...,a_k>$ knowing the former. Is there a more intelligent way to write this program than absolute brute force search across subsets of $G$ and the definition of $<S>$ as intersection of all submagmas of $G$ that contain $S$?