Deciding active structural completeness

We prove that if an n-element algebra generates the variety V\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {V}$$\end{document} which is actively structurally complete, then the cardinality of the carrier of each subdirectly irreducible algebra in V\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {V}$$\end{document} is at most n(n+1)·n2·n\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$n^{(n+1)\cdot n^{2\cdot n}}$$\end{document}. As a consequence, with the use of known results, we show that there exist algorithms deciding whether a given finite algebra A\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathbf {A}$$\end{document} generates the (actively) structurally complete variety V(A)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\textsf {V}}(\mathbf {A})$$\end{document} in the cases when V(A)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\textsf {V}}(\mathbf {A})$$\end{document} is congruence modular or V(A)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\textsf {V}}(\mathbf {A})$$\end{document} is congruence meet-semidistributive or A\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathbf {A}$$\end{document} is a semigroup.


The (A)SC-problem
A quasivariety Q is structurally complete (SC for short) if it is generated by its free algebras or, equivalently, by its free algebra F Q of denumerable rank. This means that if a quasi-identity holds in F Q , then it holds in Q. The quasi-identities which hold in F Q are called admissible in Q. We consider the following important weakening of this property, see the next subsection for the motivation. A quasi-identity q = (∀x) A quasivariety is actively (or almost) structurally complete (ASC for short) if every active and admissible in Q quasi-identity holds in Q. Here we focus on decidability of the SC and ASC properties for varieties. In order to make the problem meaningful, a variety should be given in a finitary way. There are two natural ways to do this: by giving a finite axiomatization or by giving a finite algebra generating a variety. Here we undertake the latter approach. Thus we consider the following two computational problems. 1 Problem: (A)SC-problem for varieties; Instance: A finite algebra A; Question: Is V(A) (actively) structurally complete?
(V(A) is the variety generated by A.) As it appears in Sect. 4, the solution for the analogical problems for quasivarieties is an indispensable part of the solution for the (A)SC-problem for varieties.
Problem: (A)SC-problem for quasivarieties; Instance: A finite set G of finite algebras; Question: Is Q(G) (actively) structurally complete?
(Q(G) is the quasivariety generated by G.) The clearest situation is when a finite algebra A generates the congruence distributive variety V. Then Jónsson's Lemma [2, Theorem 5.2] [5, Theorem IV. 6.8] yields that V is generated, as a quasivariety, by the finite set {B/α : B ≤ A and α is a congruence on B} of finite algebras. Thus a solution to the (A)SC problem for quasivarieties gives a solution to the (A)SC problem for varieties with the input restricted to algebras generating congruence distributive varieties.
In general, the situation is more complicated. There are many finite algebras generating varieties which are not finitely generated as quasivarieties. In fact, there does not exist an algorithm for distinguishing them [28].
However, Bergman proved that if an SC variety V is generated by a finite algebra A, then V is also generated by A as a quasivariety [1,Theorem 2.6]. Our main contribution is a proof of a similar fact for ASC varieties. Theorem 10 yields that, for a finite algebra A, if V(A) is ASC then V(A) = Q(S), where S consists of the subdirectly irreducible algebras from V(A) whose carriers have cardinalities not greater than n (n+1)·n 2·n , where n = |A|.
Thus, in order to decide whether V(A) is (A)SC first we have to check whether V(A) = Q(A) in the SC case or V(A) = Q(S) in the ASC case, where S is as in the previous paragraph. Then, if the answer is affirmative, we have to check whether Q(A) is SC or Q(S) is ASC respectively.
We know how to do the first part of the above procedure in some cases: when A is a (semi)group, when V(A) is congruence modular (this includes algebras with Mal'cev terms, e.g., algebras with (quasi)group reducts), and when V(A) is congruence meet-semidistributive (this includes algebras with semilattice reducts). We discuss it in detail in Sect. 5. We also have algorithms for the second part, i.e., algorithms for solving the (A)SC-problem for quasivarieties [1,13,30]. We review them in Sect. 3.
We do it for the sake of completeness. But also we use this occasion to rewrite the algorithm for SC proposed by Dywan [13] in algebraic terms. And we show how to modify it in order to obtain an algorithm solving the ASC-problem for quasivarieties.
Although we are focused on presenting algorithms, we do not provide their complexities. If needed, the reader may compute them. However, it seems, they are too high for any practical applications. This is due to the fact that the bounds on the cardinalities of the carriers of the subdirectly irreducible algebras in varieties under consideration are too large. The situation is a bit better for the (A)SC-problem for quasivarieties. In [30] the authors managed to check the (A)SC property for the quasivarieties generated by some small algebras. In [6,7,37] for studying admissibility, the authors used dualities. It allows for the logarithmic reduction of the sizes of considered structures.
This paper contains only one really new proof, namely the one of Theorem 10. In order to show the relevance of this theorem, we had to recall many results from the literature. Often, we reformulated them in order to adjust them to our purposes. The outlines of proofs contain information how to obtain these reformulations from the original ones.
Let us note that the following general question remains unanswered.

Question 1
Is there an algorithm solving the (A)SC problem for varieties?

Logical motivation
For the needs of the introduction, by a logic we mean a set of formulas satisfying a set of postulates. (We stay here on the informal level. It does not harm the results of the paper.) Generally, a logic L comes with a set of rules R under which L is closed. E.g., we have modus ponens for intermediate logics or modus ponens and the necessitation rule for normal modal logics. We obtain proofs by composing instances of rules from R with respect to substitusions. Thus, we have the consequence relation associated with L: for a set Ψ of formulas and a formula ϕ the consequence Ψ L ϕ holds iff there exists a proof of ϕ from Ψ with the use of rules from R. Rules under which a logic L is closed are called admissible in L. A logic L is structurally complete (SC for short) (w.r.t. R) if L is not closed under any rule outside of L . This means that all admissible in L rules are in L . The interpretation of it is that R is chosen in an optimal way. The notion of SC was introduced by Pogorzelski [33]. However, some admissible rules cannot be used in proofs. Indeed, for a logic L and a rule r = Ψ /ϕ it may be the case, that for any substitution σ , σ (Ψ ) L. A prototypical example is given by the p 2 rule {♦ p, ♦¬ p}/⊥ for modal logic S5. Such rules are called passive. By neglecting the passive rules in the definition of SC, we obtain the definition of active structural completeness (ASC for short) (w.r.t. R). It is often called almost SC. The interpretation of the ASC property is that a set R of rules for a logic L may be optimal, yet L is just ASC and not SC (w.r.t. R).
ASC appeared for the first time, though under yet another name, in [14], as an application of projective unification. However, it was appearing implicitly much earlier, see e.g. [4,32,35]. The reader may consult the monograph [34], the paper [15] and the references therein for many results concerning both properties.
One can ask whether this slight change in the definition of SC is essential. Is it the case that the class of ASC logics which are not SC is narrow (in whatever sense)? This leads to the SC versus ASC problem: which ASC logics are SC? We claim that there are plenty of ASC logics which are not SC. Hence the replacement of SC by ASC is justified. This problem was undertaken already in [15,30]. It was explicitly formulated in [8], where it was proved that a discriminator variety (which is always ASC) with two distinct constants is SC iff it is minimal or trivial. Recently, a comparison was made for tabular extensions of the modal logic K [37]. It was computed there that among normal modal logics given by frames with less than 7 vertices we have around 5% of SC and around 76% of ASC logics. Other results on this topic are recalled in [8].
This paper is inspired by the SC versus ASC problem. Is there a mechanical way to check logics with respect to both properties? We already knew that there is a method for tabular logics with an algebraic semantics given by a congruence distributive varieties. Our aim was to extend this method to more general situasions. In some sense, we succeeded (see the previous subsection). In some sense, we did not. The algorithms we present here do not seem to be practically applicable.
The paper is written in an algebraic language. The notions of admissibility and (A)SC have the algebraic counterparts [1,15]. Thus, they may be studied separately from logic. Still, our results are directly applicable to tabular strongly algraizable logics [10,16].
Let us finish with a remark that the problem of decidability of (A)SC when the logic is given syntactically is untouched.

Question 2
Are there algorithms deciding whether the logic or a consequence relation given by a finite set of axioms and rules is (actively) structurally complete?

Algebraic background
Here we describe basic notions and tools needed in this paper. For more details in universal algebra see e.g. [2,5,29].
In this paper, a first-order language is always algebraic, i.e., without relation symbols. We also assume that it has only finitely many function symbols. By a quasiidentity we mean a first-order sentence of the form where n ∈ N. We allow n to be zero and in such a case, we call the sentence an identity. A (quasi)variety is a class defined by (quasi-)identities. We say that a class is a (quasi)variety generated by a class G if it is the smallest (quasi)variety containing G. (We tacitly assume that all considered classes contain algebras in the same language.) We denote it by V(G) (Q(G) respectively). When G = {A}, we simplify the notation by writing V(A) (Q(A) respectively).
Let Q be a quasivariety. A congruence α on an algebra A is called a Q-congruence if A/α ∈ Q. Note that A ∈ Q if and only if the equality relation on A is a Q-congruence of A. The set Con Q (A) of all Q-congruences of A forms an algebraic lattice. It is a meet-subsemilattice of Con(A), the lattice of all congruences of A [20,Corollary 1.4.11]. A nontrivial algebra S ∈ Q is Q-subdirectly irreducible if the equality relation on A is completely meet irreducible in Con Q (A). Equivalently, if S embeds into the product i A i , where all A i are in Q, then there is i such that the inclusion composed with the i'th projection is injective. Note that if V is a variety and A ∈ V, then Con V (A) = Con(A). So then we drop the prefix "Q-". By Q S I we denote the class of all Q-subdirectly irreducible algebras.
Let us list basic facts about (quasi)varieties and subdirectly irreducible algebras in the following proposition. Here S, P, P U , H denote the subalgebra, direct product, ultraproduct and homomorphic image class operators (considered class operators are assumed to be composed with the isomorphic image class operator).

Proposition 1 Let Q be a quasivariety and G be a class of algebras. Then
If G is a finite set of finite algebras, then Let us note that for varieties the analog of Point 5 in Proposition 1 does not hold. Indeed, there are finite algebras generating varieties of arbitrary large subdirectly irreducible members. As an example, one may take the 8-element Dihedral or quaternion group [31]. There exists even a three-element semigroup of this type [29,Exercise 4.5.15]. Such varieties are not finitely generated as quasivarieties. We will come back to this issue in Sect. 5.

Outline of proof
Let Q be a quasivariety, G ∈ Q and W be a subset of G. We say that G is free for Q over W , and is of rank |W |, if the following universal mapping property holds: every mapping f : W → A, where A is a carrier of an algebra A in Q, has a unique homomorphic extensionf : G → A. If κ is a cardinal greater than 0, then a free algebra of rank κ for Q exists and is unique up to isomorphism. For κ = 0 the same holds iff there is a constant in the language. (We follow the convention that the carriers of algebras are nonempty.) A free algebra for Q of rank κ is denoted by F Q (κ) and if κ = ℵ 0 by F Q . We will use the following well-known facts.

Proposition 2
Let G be a set of algebras and κ be a cardinal number. Then Note that Point 2 gives us not only a bound on the cardinality on the carrier of F V(G) (κ) but also, when κ is finite, may be used for an algorithmic construction of this algebra.
Outline of proof Point 1 follows directly from the definition of free algebras and the fact that V(G) = HQ(G), see Proposition 1.
Point 2 is a known folklore.
For Point 3 notice that, by the universal mapping property, every ) (every variety is generated by its free algebra of denumerable rank). Thus the statement follows from the preceding points.
Let us finish this section with a remark that for a finite algebra A and a finite set of finite algebras G we can algorithmically check whether A ∈ Q(G) and A ∈ V(G).
. This may be checked by a non-deterministic polynomial time algorithm. Moreover, by the universal mapping property,

Solutions to the (A)SC-problem for quasivarieties
Here we recall algorithms allowing to decide (A)SC for finitely generated quasivarieties. The first one is due to Dywan [13]. It was originally formulated for consequence relations and just for SC. However, a small modification gives an algorithm for ASC too. The second algorithm was formulated by Metcalfe and Röthlisberger in [30]. The SC case follows easily from the fact, due to Bergman [1], that a quasivariety is SC iff it is generated by its free algebras. This is why we call it Bergman's algorithm, although it was formulated in [30].
Let us note that these two solutions are based on different ideas. The one given by Dywan rely on the observation that if the carriers of the members of G are of cardinality at most l, then for the SC of Q(G) it is enough to check only quasi-identities with at most l variables and for the ASC with at most l · l m·l m variables, where m = |G|. (The number l m·l m is a bound on the cardinality of the carrier of F Q(G) (1), see Proposition 2 Point 2.) Metcalfe's and Röthlisberger's solution is based on studying Q(G)-subdirectly irreducible algebras.
The following lemma is crucial in Dywan's approach. A substitution σ is l-short if there is an l-element set Y of variables such that σ (x) ∈ Y for every variable x. For a quasi-identity q = (∀x) s i (x) ≈ t i (x) → s(x) ≈ t(x) and a substitution σ let whereȳ is a tuple of all variables appearing in the quantifier free part of q σ . Note that if q is admissible in Q, then q σ is also admissible in Q.

Lemma 3 [13, Point II]
Let Q be the quasivariety generated by algebras with the carriers of cardinality at most l. Then for every quasi-identity q which is not valid in Q there is an l-short substitution σ such that q σ is not valid in Q.
and let X be the set of variables appearing in q. By assumption, there is an at most l-element algebra A in Q such that q does not hold in A. This means that there is an evaluation v : Since A has at most l elements, there is an l-element set Y of variables and an embedding ι : A → Y . Then the substitution σ = ι • v satisfies the requested condition.
Here is an adaptation of Lemma 3 to the "active" context.

Lemma 4
Let Q be the quasivariety generated by algebras of cardinality at most l. Let M be a smallest subalgebra of F Q (1). Then for every quasi-identity q which is not valid in Q but active in Q there is an (l · |M|)-short substitution σ such that q σ is not valid in Q but is active in Q.
Proof We proceed similarly as in the proof of Lemma 3. Let q and v be as there. Since q is active in Q, there is an evaluation w : , satisfies the requested condition.

Algorithm 1: Dywan's algorithm for SC
Input: A finite set G of finite algebras begin l ← max{|A| : A ∈ G}; for A ∈ G do k A ← the size of a smallest generating set for A; T ← a set of terms representing elements of F Q(G) (l); Q ← the set of all quasi-identities (up to equiv.) with terms in T ; for q ∈ Q do if F Q(G) (k) | q and G | q then Return No; Return Yes; Algorithm 2: Dywan's algorithm for ASC Input: A finite set G of finite algebras begin l ← max{|A| : A ∈ G}; for A ∈ G do k A ← the size of a smallest generating set for A; T ← a set of terms representing elements of F Q(G) (l · |M|); Q ← the set of all quasi-identities (up to equiv.) with terms in T ; for q ∈ Q do if F Q(G) (k) | q and the premise of q is satisfiable in M and G | q then Return No; Return Yes;

Proposition 5 Let Q be a quasivariety generated by algebras whose carriers have cardinalities at most l. Let M be a smallest subalgebra of F Q (1). Then Q is (A)SC if and only if all admissible (and active) in Q quasi-identities with at most l (or l · |M|) variables are valid in Q.
Proof The necessity is obvious. For the sufficiency, let us assume that a quasivariety Q satisfies the condition. Let q be an (active in Q) quasi-identity which is not valid in Q. By Lemmas 3 and 4, there is an l-short ((l · |M|)short) substitution σ such that q σ does not hold in Q (and is active in Q). By assumption, q σ is not admissible in Q. Hence q is not admissible in Q too.
From Proposition 5 and Proposition 2, we obtain the following fact.

Theorem 6 Dywan's algorithms solve the SC and the ASC problems for quasivarieties.
In the following algorithms the procedure MinGenSet from [30, Section 3] is used. Let G be a finite set of finite algebras. Let Q(G) i S I be a class which consists of one representative from each isomorphism class contained in Q(G) S I . Then, by Proposition 1 Point 3, Q(G) i S I is a finite set. Moreover, it is ordered by the embeddability relation →. Then MinGenSet(G) is the set, up to isomorphism of members, of maximal algebras in (Q(G) i S I , →). It is a minimal generating set for Q(G) in the sense described in [30, Section 3].

Algorithm 3: Bergman's algorithm for SC
Input: A finite set G of finite algebras begin G ← MinGenSet(G); for S ∈ G do k S ← the size of a smallest generating set for S; Return Yes;

Theorem 7 Bergman's algorithm solves the SC problem for quasivarieties. Metcalfe's and Röthlisberger's algorithm solves the ASC problem for quasivarieties
Before outlining the proof let us note that two things are not really necessary for the correctness of these algorithms. They are just simple optimizations. The first thing is the set G . One can skip its construction and work with G [30]. The second thing is the number k. The algorithms stay correct if we simply define k to be the maximal cardinality of a carrier of a member of G. However, due to the fact that the cardinalities of the carriers of free algebras may grow doubly exponentially with respect to the rank, it makes sense to keep this number as small as possible.

Residual bounds for (A)SC varieties
Let κ be a cardinal number. We say that a variety V is residually κ-bounded if every carrier of a subdirectly irreducible algebra in V has cardinality smaller than κ. If κ is finite, by Proposition 1 Point 3, it is equivalent to say that V is generated, as a quasivariety, by its members with the carriers of cardinality less than κ. (For infinite κ it is not true. Indeed, every quasivariety is generated by its finitely generated members. Their carriers have cardinalities at most λ = ℵ 0 +the cardinality of the language. Hence, as a counterexample one may take any variety which is not λ + -bounded, where λ + is the successor cardinal for λ [38].) Our main contribution in this paper is the following fact.

Theorem 10 Let A be a finite n-element algebra and V = V(A).
If V is ASC, then V is residually n (n+1)·n 2·n + 1 -bounded. If there is a constant in the language, then V is residually n 2·n 2 + 1 -bounded.
Proof Let M be a subalgebra of F V (1). Let us use Lemma 9 two times: when G = {A} and when G = V S I . The second case is justified by Proposition 1 Point 3. We obtain that Let us now consider an algebra S ∈ V S I . Our aim is to find a bound on the cardinality of S. Assume that the least nontrivial congruence on S is generated by a pair (r , s). For a, b ∈ M let θ a,b be a maximal Q(A × M)-congruence on S × M such ((r , a), (s, b)) / ∈ θ a,b . The existence of θ a,b follows from Zorn's Lemma, the fact that a union of a chain of Q(A × M)-congruences is a Q(A × M)-congruence and, most importantly, the fact that there exists at least one Q(A × M)-congruence on S × M not containing ((r , a), (s, b)), namely the identity relation. This follows from ( * ). Let , a), ( p, b)) : p ∈ S and a, b ∈ M}.
The relation π is the kernel of the projection on the first coordinate of S × M.
We claim that a,b∈M Indeed, assume that (( p, c), (q, d)) ∈ θ a,b for some distinct p, q ∈ S. Then (r , s) is in the congruence of S generated by ( p, q). Let us consider Mal'cev's scheme witnessing it [5,Theorem V.3.3]. It is given by terms t 0 (x,ȳ), . . . , t l (x,ȳ), elements u 0 , v 0 , . . . , u l , v l ∈ {p, q}, and a tuplew of elements of S such that in S we have Letḡ be an arbitrary tuple of elements of M of the same lenght asw. Let Then, ((r , e), (s, f )) is in the congruence on S × M generated by (( p, c), (q, d)).
We conclude that there is a surjective homomorphism This yields that Combining all these facts, we obtain that |S| ≤ (|A| · |M|) |M| 2 = |A| |M| 2 · |M| |M| 2 If we have a constant in the language, we may take M = F V (0). Then, by Proposition 2 Point 2, |M| ≤ |A| = n and |S| ≤ n 2·n 2 .

A partial solution to the (A)SC-problem for varieties
By the RES-problem we mean the following computational problem Problem: RES-problem; Instance: A pair (A, m), where A is a finite algebra and m ∈ N; Question: Is V(A) residually m-bounded?
Proposition 11 Let C be a set of finite algebras. 2 If the exists an algorithm solving the RES-problem when the input algebra is from C, then there is an algorithm solving the (A)SC-problem for varieties when the input algebra is from C.
Proof Assume that the exists an algorithm Res answering to the question in the RESproblem when the input algebra is in C. Let Sc and Asc be algorithms from Sect. 3 answering to the questions in the SC-problem and the ASC-problem for quasivarieties respectively. For a variety V with a finite residual bound, let V i S I be a class which consists of one representative from each isomorphism class contained in V S I . By Theorems 6, 7, 10 and Proposition 8, the following algorithms solves the SC-problem and the ASC-problem for varieties with the input from C. There are known algorithms solving the RES problems when the input algebras are from particular sets. For example, we already in the introduction noted that it is the case for the set of finite algebras generating congruence-distributive varieties. Let us recall some other facts of greater generality. Note however, that algorithms from the literature, in most cases, are of very high complexity and are not applicable in practice.
A variety V is congruence meet-semidistributive if for every A ∈ V the congruence lattice Con(A) satisfies the following quasi-identity As an example, note that if B has a semilattice term operation, then V(B) is congruence meet-semidistributive [39]. A variety V is congruence modular if for every A the congrunece lattice Con(A) satisfies the following quasi-identity As an example, note that if B has a Mal'cev term, i.e., a term t(x, y, z) such that B | (∀x, y, z) t(x, y, y) ≈ t(y, y, x) ≈ x, then V(B) is congruence modular [11]. Thus every algebra with a (quasi)group reduct generates a congruence modular variety.
It will be convenient to separate the needed results about semigroups. Let L, R and N be two-element semigroups satisfying the respective identities (∀x, y) x y ≈ x, (∀x, y) x y ≈ y and (∀x, y, u, v) x y ≈ uv. Let I be a two-element semilattice. Let P (Q) be the semigroup with the carrier {e, u, 0} satisfying e 2 = e, eu = u (ue = u) and x y = 0 in the other cases. A semigroup G is a group if it has a neutral element e and for every a ∈ G there exists an element b ∈ G such that ab = ba = e. And is a group of exponent p if for every a ∈ G, a p = e. Let A be a finite semigroup. Then A | (∀x) x i+ p ≈ x i for some finite i and p. In fact, we may take i = |A| and p = |A|!. In such a case, every group in V = V(A) is a group of exponent p. It follows that the class of all groups in V forms a variety. Let us denote it by V g . Let A g be the product of all maximal subsemigroups of A which are groups. Let Z p be a cyclic semigroup of order p which is a group. We formulate a characterization of residually bounded finitely generated varieties of semigroups in the form which may be checked algorithmically.

Theorem 12 Let A be a finite semigroup. Then V(A) is residually bounded by a finite number if and only if one of the conditions holds
Outline of proof It was proved independently by Golubov and Sapir [18,19], Kublanovskiȋ [24,25] and McKenzie [26,27]. The sufficiency follows from the main theorem in [19]. For the necessity, let us assume that V = V(A) has a finite residual bound. Then, again, by the main theorem in [19], there are three cases to consider: (1) Either V = V(K ∪ {G}), where K ⊆ {L, R, N, I} and G is a group with all Sylow subgroups abelian. As G ∈ V, G ∈ V g . By [26, Theorem 1 and Lemma 28], V g = V(A g ). Hence A ∈ V(L × R × N × I × A g ). Moreover, V g is also finitely residually bounded. Thus, by [31,Lemma 1], all Sylow subgroups of A g are abelian. (2) Or V = V(K ∪ {C}), where K ⊆ {L, P} and C is a finite cyclic group. As C ∈ V g , C ∈ H(Z p ). (3) Or V = V(K ∪ {C}), where K ⊆ {R, Q} and C is a finite cyclic group. In this case we may also infer that C ∈ H(Z p ).

Corollary 13
There are algorithms solving the RES-problem when the input algebras are from one of the following sets: 1. the set of finite algebras generating congruence meet-semidistributive varieties; 2. the set of finite algebras generating congruence modular varieties; 3. the set of finite semigroups.
Consequently, there are algorithms solving the (A)SC-problem for varieties, when restricted to any of the listed sets of algebras.
Outline of proof Let C be one of the listed sets. The results from the literature we are going to recall are of the following or stronger form. There exists a computable function n C such that for every algebra A ∈ C either V(A) is not residually m-bounded for every m ∈ N, or V(A) is residually n C (A)-bounded, and it is decidable which case holds. Thus we have the following algorithm. is the commutator operation). This condition is decidable. (3) By Theorem 12, we may decide whether a finite semigroup A generates the finitely residually bounded variety. Moreover, from e.g., the main theorem in [19], we may infer that the cardinalities of the carriers of the subdirectly irreducible algebras in V(A) are smaller than 2 · |A| + 2 in the second and third cases, and are smaller than max(3, r ), were r is a bound on the cardinality of the carriers of algebras in V(A) g S I , in the first case. As V(A) g is congruence modular, r may be computed as in the previous point of this theorem.
Corollary 13 gives examples of prominent sets of finite algebras C such that the exist algorithms solving the the RES-problem when the input algebra is in C. But there are much more results of this type in algebraic literature. E.g., the reader may consult [9] for the case of varieties with the congruence extension property and the Fraser-Horn propery (the conclusion of Jónsson's Lemma holds there), [22,Section 8] for the case of strongly nilpotent varieties, [23,Section 6] for the case of abelian varieties, or [12] for the case of varieties of combinatorial semigroups with involution. Also, by [21,Theorem 10.4], the set in Point 2 of Corollary 13 may be extended to the set of finite algebras generating varieties omitting types 1 and 5 in the sense of tame congruence theory.
Let us finish the paper with a remark that for the decidability of the (A)SC-problem for varieties, a seemingly weaker problem than the RES-problem may be considered. Let f : N → N be a computable function. Let us consider the following problem.
By Proposition 8, the decidability of RES f for f (n) = n + 1 yields the decidability of the SC-problem for varieties. Similarly, by Theorem 10, the decidability of RES f for f (n) = n (n+1)·n 2·n + 1 yields the decidability of the ASC-problem and the SCproblem for varieties.
Question 3 Let f : N → N be a computable function. Does there exist an algorithm solving the Res f -problem?