1 Introduction

1.1 The (A)SC-problem

A quasivariety \(\mathcal {Q}\) is structurally complete (SC for short) if it is generated by its free algebras or, equivalently, by its free algebra \(\mathbf {F}_\mathcal {Q}\) of denumerable rank. This means that if a quasi-identity holds in \(\mathbf {F}_\mathcal {Q}\), then it holds in \(\mathcal {Q}\). The quasi-identities which hold in \(\mathbf {F}_\mathcal {Q}\) are called admissible in\(\mathcal {Q}\). We consider the following important weakening of this property, see the next subsection for the motivation. A quasi-identity \(q=(\forall \bar{x})\bigwedge s_i(\bar{x})\approx t_i(\bar{x})\rightarrow s(\bar{x})\approx t(\bar{x})\) is active in\(\mathcal {Q}\) if \(\mathbf {F}_\mathcal {Q}\models (\exists \bar{x}) \bigwedge s_i(\bar{x})\approx t_i(\bar{x})\). A quasivariety is actively (or almost) structurally complete (ASC for short) if every active and admissible in \(\mathcal {Q}\) quasi-identity holds in \(\mathcal {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.Footnote 1

figure a

(\({{\textsf {V}}}(\mathbf {A})\) is the variety generated by \(\mathbf {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.

figure b

(\({\textsf {Q}}(\mathcal {G})\) is the quasivariety generated by \(\mathcal {G}\).)

The clearest situation is when a finite algebra \(\mathbf {A}\) generates the congruence distributive variety \(\mathcal {V}\). Then Jónsson’s Lemma [2, Theorem 5.2] [5, Theorem IV.6.8] yields that \(\mathcal {V}\) is generated, as a quasivariety, by the finite set \(\{\mathbf {B}/\alpha : \mathbf {B}\le \mathbf {A}\text { and }\alpha \text { is a congruence on }\mathbf {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 \(\mathcal {V}\) is generated by a finite algebra \(\mathbf {A}\), then \(\mathcal {V}\) is also generated by \(\mathbf {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 \(\mathbf {A}\), if \({{\textsf {V}}}(\mathbf {A})\) is ASC then \({{\textsf {V}}}(\mathbf {A})={\textsf {Q}}(\mathcal {S})\), where \(\mathcal {S}\) consists of the subdirectly irreducible algebras from \({{\textsf {V}}}(\mathbf {A})\) whose carriers have cardinalities not greater than \(n^{(n+1)\cdot n^{2\cdot n}}\), where \(n=|A|\).

Thus, in order to decide whether \({{\textsf {V}}}(\mathbf {A})\) is (A)SC first we have to check whether \({{\textsf {V}}}(\mathbf {A})={\textsf {Q}}(\mathbf {A})\) in the SC case or \({{\textsf {V}}}(\mathbf {A})={\textsf {Q}}(\mathcal {S})\) in the ASC case, where \(\mathcal {S}\) is as in the previous paragraph. Then, if the answer is affirmative, we have to check whether \({\textsf {Q}}(\mathbf {A})\) is SC or \({\textsf {Q}}(\mathcal {S})\) is ASC respectively.

We know how to do the first part of the above procedure in some cases: when \(\mathbf {A}\) is a (semi)group, when \({{\textsf {V}}}(\mathbf {A})\) is congruence modular (this includes algebras with Mal’cev terms, e.g., algebras with (quasi)group reducts), and when \({{\textsf {V}}}(\mathbf {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?

1.2 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 rulesR 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 \(\varPsi \) of formulas and a formula \(\varphi \) the consequence \(\varPsi \vdash _L \varphi \) holds iff there exists a proof of \(\varphi \) from \(\varPsi \) with the use of rules from R. Rules under which a logic L is closed are called admissible inL. A logic L is structurally complete (SC for short) (w.r.t. R) if L is not closed under any rule outside of \(\vdash _L\). This means that all admissible in L rules are in \(\vdash _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=\varPsi /\varphi \) it may be the case, that for any substitution \(\sigma \), \(\sigma (\varPsi )\not \subseteq L\). A prototypical example is given by the \(p_2\) rule \(\{\Diamond p,\Diamond \lnot p\}/\bot \) 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?

2 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 quasi-identity we mean a first-order sentence of the form

$$\begin{aligned} (\forall \bar{x})\, [s_1(\bar{x})\approx t_1(\bar{x})\wedge \cdots \wedge s_{n}(\bar{x})\approx t_{n}(\bar{x})\rightarrow s(\bar{x})\approx t(\bar{x})], \end{aligned}$$

where \(n\in \mathbb {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 \(\mathcal {G}\) if it is the smallest (quasi)variety containing \(\mathcal {G}\). (We tacitly assume that all considered classes contain algebras in the same language.) We denote it by \({\textsf {V}}(\mathcal {G})\) (\(\textsf {Q}(\mathcal {G})\) respectively). When \(\mathcal {G} = \{\mathbf {A}\}\), we simplify the notation by writing \({\textsf {V}}(\mathbf {A})\) (\(\textsf {Q}(\mathbf {A})\) respectively).

Let \(\mathcal {Q}\) be a quasivariety. A congruence \(\alpha \) on an algebra \(\mathbf {A}\) is called a \(\mathcal {Q}\)-congruence if \(\mathbf {A}/\alpha \in \mathcal {Q}\). Note that \(\mathbf {A}\in \mathcal {Q}\) if and only if the equality relation on A is a \(\mathcal {Q}\)-congruence of \(\mathbf {A}\). The set \({{\,\mathrm{Con}\,}}_\mathcal {Q}(\mathbf {A})\) of all \(\mathcal {Q}\)-congruences of \(\mathbf {A}\) forms an algebraic lattice. It is a meet-subsemilattice of \({{\,\mathrm{Con}\,}}(\mathbf {A})\), the lattice of all congruences of \(\mathbf {A}\) [20, Corollary 1.4.11]. A nontrivial algebra \(\mathbf {S}\in \mathcal {Q}\) is \(\mathcal {Q}\)-subdirectly irreducible if the equality relation on A is completely meet irreducible in \({{\,\mathrm{Con}\,}}_\mathcal {Q}(\mathbf {A})\). Equivalently, if \(\mathbf {S}\) embeds into the product \(\prod _i\mathbf {A}_i\), where all \(\mathbf {A}_i\) are in \(\mathcal {Q}\), then there is i such that the inclusion composed with the i’th projection is injective. Note that if \(\mathcal {V}\) is a variety and \(\mathbf {A}\in \mathcal {V}\), then \({{\,\mathrm{Con}\,}}_\mathcal {V}(\mathbf {A})={{\,\mathrm{Con}\,}}(\mathbf {A})\). So then we drop the prefix “\(\mathcal {Q}\)-”. By \(\mathcal {Q}_{SI}\) we denote the class of all \(\mathcal {Q}\)-subdirectly irreducible algebras.

Let us list basic facts about (quasi)varieties and subdirectly irreducible algebras in the following proposition. Here \(\textsf {S}\), \(\textsf {P}\), \(\textsf {P}_{\textsf {U}}\), \(\textsf {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 \(\mathcal {Q}\) be a quasivariety and \(\mathcal {G}\) be a class of algebras. Then

  1. 1.

    \({{\textsf {V}}}(\mathcal {G})={\textsf {HSP}}(\mathcal {G})\);

  2. 2.

    \({\textsf {Q}}(\mathcal {G})={\textsf {SPP}_\textsf {U}}(\mathcal {G})\);

  3. 3.

    \(\mathcal {Q}={\textsf {SP}}(\mathcal {Q}_{SI})\).

If \(\mathcal {G}\) is a finite set of finite algebras, then

  1. 4.

    \({\textsf {Q}}(\mathcal {G})={\textsf {SP}}(\mathcal {G})\);

  2. 5.

    \({\textsf {Q}}(\mathcal {G})_{SI}\subseteq {\textsf {S}}(\mathcal {G})\).

Outline of proof

For Point 1 see e.g. [2, Theorem 4.41], [5, Theorem II.9.5] or [20, Theorem 2.1.12]. For Point 2 see [5, Theorem V.2.25] or [20, Corollary 2.3.4]. One may also consult [36, Corollary 2.4] for a simultaneous proof of Points 1 and 2. Point 3 follows from Mal’cev’s theorem [20, Theorem 3.1.1]. For Varieties it was proved by Birkhoff, see [2, Theorem 3.24] or [5, Theorem II.8.6]. Point 4 follows from Point 2 and [5, Lemma IV.6.5]. Point 5 follows from the definition of subdirect irreducibility. \(\square \)

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.

Let \(\mathcal {Q}\) be a quasivariety, \(\mathbf {G}\in \mathcal {Q}\) and W be a subset of G. We say that \(\mathbf {G}\) is free for\(\mathcal {Q}\)overW, and is of rank |W|, if the following universal mapping property holds: every mapping \(f:W\rightarrow A\), where A is a carrier of an algebra \(\mathbf {A}\) in \(\mathcal {Q}\), has a unique homomorphic extension \(\bar{f}:\mathbf {G}\rightarrow \mathbf {A}\). If \(\kappa \) is a cardinal greater than 0, then a free algebra of rank \(\kappa \) for \(\mathcal {Q}\) exists and is unique up to isomorphism. For \(\kappa =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 \(\mathcal {Q}\) of rank \(\kappa \) is denoted by \(\mathbf {F}_\mathcal {Q}(\kappa )\) and if \(\kappa =\aleph _0\) by \(\mathbf {F}_\mathcal {Q}\). We will use the following well-known facts.

Proposition 2

Let \(\mathcal {G}\) be a set of algebras and \(\kappa \) be a cardinal number. Then

  1. 1.

    \(\mathbf {F}_{{\textsf {V}}({\mathcal {G}})}(\kappa )=\mathbf {F}_{\textsf { Q}({\mathcal {G}})}(\kappa )\);

  2. 2.

    \(\mathbf {F}_{{\textsf {V}}({\mathcal {G}})}(\kappa )\) is isomorphic to the subalgebra of \(\mathbf {A}^{A^\kappa }\) generated by the set of projections, where \(\mathbf {A}=\prod \mathcal {G}\);

  3. 3.

    if every algebra from \(\mathcal {G}\) is \(\kappa \)-generated, then \({\textsf {Q}}(\mathbf {F}_{\textsf {Q}({\mathcal {G}})}(\kappa ))={\textsf {Q}}(\mathbf {F}_{\textsf { Q}({\mathcal {G}})})\).

Note that Point 2 gives us not only a bound on the cardinality on the carrier of \(\mathbf {F}_{{\textsf {V}}({\mathcal {G}})}(\kappa )\) but also, when \(\kappa \) 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 \({{\textsf {V}}({\mathcal {G}})}={\textsf {HQ}({\mathcal {G}})}\), see Proposition 1.

Point 2 is a known folklore. For \(i<\kappa \) let \(\pi (i):A^\kappa \rightarrow A;\; u\mapsto u(i)\). Then \(W=\{\pi (i) : i\in \kappa \}\) is the set of all projections from \(A^\kappa \) into A and \(\pi :\kappa \rightarrow W\) is a bijection. Let \(\mathbf {G}\) be the subalgebra of \(\mathbf {A}^{A^\kappa }\) generated by W. Let \(f:W\rightarrow A\). By [2, Proposition 4.25], it is enough to find a homomorphic extension \(\bar{f}:\mathbf {G}\rightarrow \mathbf {A}\) of f. So for \(u\in G\), put \(\bar{f}(u)=u(f\circ \pi )\).

For Point 3 notice that, by the universal mapping property, every \(\mathbf {B}\in \mathcal {G}\) is a homomorphic image of \(\mathbf {F}_{\textsf {Q}({\mathcal {G}})}(\kappa )\). Thus \({\textsf {V}}({\mathcal {G}})= V(\mathbf {F}_{\textsf {Q}({\mathcal {G}})}(\kappa ))=V(\mathbf {F}_{\textsf {V}({\mathcal {G}})})\) (every variety is generated by its free algebra of denumerable rank). Thus the statement follows from the preceding points. \(\square \)

Let us finish this section with a remark that for a finite algebra \(\mathbf {A}\) and a finite set of finite algebras \(\mathcal {G}\) we can algorithmically check whether \(\mathbf {A}\in {\textsf {Q}}(\mathcal {G})\) and \(\mathbf {A}\in {{\textsf {V}}}(\mathcal {G})\). Indeed, by Proposition 1 Point 4, \(\mathbf {A}\in {\textsf {Q}}(\mathcal {G})\) iff for every pair ab of distinct elements ab in A there is a homomorphism \(h:\mathbf {A}\rightarrow \mathbf {B}\in \mathcal {G}\) such that \(h(a)\ne h(b)\). This may be checked by a non-deterministic polynomial time algorithm. Moreover, by the universal mapping property, \(\mathbf {A}\in {{\textsf {V}}(\mathcal {G})}\) iff \(\mathbf {A}\) is a homomorphic image of \(\mathbf {F}_{{{\textsf {V}}}(\mathcal {G})}(|A|)\). This may be checked by a double exponential time algorithm [3, Theorem 6.7].

3 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 \(\mathcal {G}\) are of cardinality at most l, then for the SC of \({\textsf {Q}}(\mathcal {G})\) it is enough to check only quasi-identities with at most l variables and for the ASC with at most \(l\cdot l^{m\cdot l^m}\) variables, where \(m=|\mathcal {G}|\). (The number \(l^{m\cdot l^m}\) is a bound on the cardinality of the carrier of \(\mathbf {F}_{\textsf {Q}(\mathcal {G})}(1)\), see Proposition 2 Point 2.) Metcalfe’s and Röthlisberger’s solution is based on studying \(\textsf {Q}(\mathcal {G})\)-subdirectly irreducible algebras.

The following lemma is crucial in Dywan’s approach. A substitution \(\sigma \) is l-short if there is an l-element set Y of variables such that \(\sigma (x)\in Y\) for every variable x. For a quasi-identity \(q=(\forall \bar{x})\bigwedge s_i(\bar{x})\approx t_i(\bar{x})\rightarrow s(\bar{x})\approx t(\bar{x})\) and a substitution \(\sigma \) let

$$\begin{aligned} q^\sigma =(\forall \bar{y})\bigwedge s_i(\sigma (\bar{x}))\approx t_i(\sigma (\bar{x}))\rightarrow s(\sigma (\bar{x}))\approx t(\sigma (\bar{x})), \end{aligned}$$

where \(\bar{y}\) is a tuple of all variables appearing in the quantifier free part of \(q^\sigma \). Note that if q is admissible in \(\mathcal {Q}\), then \(q^\sigma \) is also admissible in \(\mathcal {Q}\).

Lemma 3

[13, Point II] Let \(\mathcal {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 \(\mathcal {Q}\) there is an l-short substitution \(\sigma \) such that \(q^\sigma \) is not valid in \(\mathcal {Q}\).

Proof

Let \(q=(\forall \bar{x})\bigwedge s_i(\bar{x})\approx t_i(\bar{x})\rightarrow s(\bar{x})\approx t(\bar{x})\) and let X be the set of variables appearing in q. By assumption, there is an at most l-element algebra \(\mathbf {A}\) in \(\mathcal {Q}\) such that q does not hold in \(\mathbf {A}\). This means that there is an evaluation \(v:X\rightarrow A\) such that in \(\mathbf {A}\) we have \( s_i(v(\bar{x}))= t_i(v(\bar{x}))\) for all i and \(s(v(\bar{x}))\not = t(v(\bar{x}))\). Since A has at most l elements, there is an l-element set Y of variables and an embedding \(\iota :A\rightarrow Y\). Then the substitution \(\sigma =\iota \circ v\) satisfies the requested condition. \(\square \)

Here is an adaptation of Lemma 3 to the “active” context.

Lemma 4

Let \(\mathcal {Q}\) be the quasivariety generated by algebras of cardinality at most l. Let \(\mathbf {M}\) be a smallest subalgebra of \(\mathbf {F}_{\mathcal {Q}}(1)\). Then for every quasi-identity q which is not valid in \(\mathcal {Q}\) but active in \(\mathcal {Q}\) there is an \((l\cdot |M|)\)-short substitution \(\sigma \) such that \(q^\sigma \) is not valid in \(\mathcal {Q}\) but is active in \(\mathcal {Q}\).

Proof

We proceed similarly as in the proof of Lemma 3. Let q and v be as there. Since q is active in \(\mathcal {Q}\), there is an evaluation \(w:X\rightarrow F_{\mathcal {Q}}\) such that in \(\mathbf {F}_\mathcal {Q}\) we have \(s_i(w(\bar{x}))= t_i(w(\bar{x}))\) for all i. By the universal mapping property, there exists a homomorphism \(h:\mathbf {F}_\mathcal {Q}\rightarrow \mathbf {M}\). Then in \(\mathbf {M}\) we have the equalities \(s_i(h\circ w(\bar{x}))= t_i(h\circ w(\bar{x}))\) for all i. Let Y be a set of variables of cardinality \(l\cdot |M|\) and let \(\iota :A\times M\rightarrow Y\) be an embedding. Then the following substitution \(\sigma =\iota \circ (v,h\circ w)\), where \((v,h\circ w):X\rightarrow A\times M;\; x\mapsto (v(x),h\circ w(x))\), satisfies the requested condition. \(\square \)

figure c
figure d

Proposition 5

Let \(\mathcal {Q}\) be a quasivariety generated by algebras whose carriers have cardinalities at most l. Let \(\mathbf {M}\) be a smallest subalgebra of \(\mathbf {F}_\mathcal {Q}(1)\). Then \(\mathcal {Q}\) is (A)SC if and only if all admissible (and active) in \(\mathcal {Q}\) quasi-identities with at most l (or \(l\cdot |M|\)) variables are valid in \(\mathcal {Q}\).

Proof

The necessity is obvious. For the sufficiency, let us assume that a quasivariety \(\mathcal {Q}\) satisfies the condition. Let q be an (active in \(\mathcal {Q}\)) quasi-identity which is not valid in \(\mathcal {Q}\). By Lemmas 3 and 4, there is an l-short (\((l\cdot |M|)\)-short) substitution \(\sigma \) such that \(q^\sigma \) does not hold in \(\mathcal {Q}\) (and is active in \(\mathcal {Q}\)). By assumption, \(q^\sigma \) is not admissible in \(\mathcal {Q}\). Hence q is not admissible in \(\mathcal {Q}\) too. \(\square \)

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 \(\mathcal {G}\) be a finite set of finite algebras. Let \({\textsf {Q}}({\mathcal {G}})_{SI}^i\) be a class which consists of one representative from each isomorphism class contained in \({\textsf {Q}}({\mathcal {G}})_{SI}\). Then, by Proposition 1 Point 3, \({\textsf {Q}}({\mathcal {G}})_{SI}^i\) is a finite set. Moreover, it is ordered by the embeddability relation \(\hookrightarrow \). Then \(MinGenSet(\mathcal {G})\) is the set, up to isomorphism of members, of maximal algebras in \(({\textsf {Q}}(\mathcal {G})_{SI}^i,\hookrightarrow )\). It is a minimal generating set for \({\textsf {Q}}(\mathcal {G})\) in the sense described in [30, Section 3].

figure e
figure f

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 \(\mathcal {G}'\). One can skip its construction and work with \(\mathcal {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 \(\mathcal {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.

Outline of proof

Let us first note that, by Proposition 2 Point 3, we have \({\textsf {Q}}(\mathbf {F}_{\textsf {Q}(\mathcal {G})})={\textsf {Q}}(\mathbf {F}_{\textsf {Q}(\mathcal {G})}(k))\), where k is the number computed in both algorithms.

Now, for the SC case see [1, Theorem 2.3], [30, Propositions 4.7 and 5.6] or just use the fact that a quasivariety \(\mathcal {Q}\) is SC iff \(\mathcal {Q}={\textsf {Q}}(\mathbf {F}_\mathcal {Q})\) and Proposition 1 point 5. For the ASC case, see [30, Theorem 4.10, Proposition 5.8] or [15, Corollary 3.2] \(\square \)

4 Residual bounds for (A)SC varieties

Let \(\kappa \) be a cardinal number. We say that a variety \(\mathcal {V}\) is residually\(\kappa \)-bounded if every carrier of a subdirectly irreducible algebra in \(\mathcal {V}\) has cardinality smaller than \(\kappa \). If \(\kappa \) is finite, by Proposition 1 Point 3, it is equivalent to say that \(\mathcal {V}\) is generated, as a quasivariety, by its members with the carriers of cardinality less than \(\kappa \). (For infinite \(\kappa \) it is not true. Indeed, every quasivariety is generated by its finitely generated members. Their carriers have cardinalities at most \(\lambda =\aleph _0+\)the cardinality of the language. Hence, as a counterexample one may take any variety which is not \(\lambda ^+\)-bounded, where \(\lambda ^+\) is the successor cardinal for \(\lambda \) [38].)

Proposition 8

[1, Theorem 2.9]. Let \(\mathbf {A}\) be a finite algebra and \(\mathcal {V}={{\textsf {V}}}(\mathbf {A})\). If \(\mathcal {V}\) is SC, then \(\mathcal {V}\) is residually \((|A|+1)\)-bounded.

Proof

By Proposition 2 Point 2, \(\mathbf {F}_\mathcal {V}\in {\textsf {Q}}(\mathbf {A})\). By SC of \(\mathcal {V}\), \(\mathcal {V}=\textsf {Q}(\mathbf {F}_\mathcal {V})\). Thus, \(\mathcal {V}=\textsf {Q}(\mathbf {A})\) and, by Proposition 1 Point 5, \(\mathcal {V}_{SI}\subseteq \textsf {S}(\mathbf {A})\). \(\square \)

Lemma 9

Let \(\mathcal {G}\) be a class of algebras, \(\mathcal {V}={{\textsf {V}}}(\mathcal {G})\) and \(\mathbf {M}\) be a subalgebra of \(\mathbf {F}_\mathcal {V}(1)\). If \(\mathcal {V}\) is ASC, then \({\textsf {Q}}(\mathbf {F}_\mathcal {V})={\textsf {Q}}(\{\mathbf {B}\times \mathbf {M}:\mathbf {B}\in \mathcal {G}\})\).

Outline of proof

The inclusion \(\supseteq \) follows from [15, Corollary 3.2], see also Theorem 7 and the following remark. For the opposite inclusion, observe that \({\mathcal {G}}\subseteq \textsf {H}(\{\mathbf {B}\times \mathbf {M}:\mathbf {B}\in \mathcal {G}\})\). Hence, by Proposition 1 Point 1, we have \(\mathcal {V}={{\textsf {V}}}(\{\mathbf {B}\times \mathbf {M}: \mathbf {B}\in {\mathcal {G}}\})\). This, by Proposition 2 Point 2, yields that \(\mathbf {F}_\mathcal {V}\in {\textsf {Q}}(\{\mathbf {B}\times \mathbf {M}: \mathbf {B}\in {\mathcal {G}}\})\). Also, one may extract the proof from the proof of [30, Theorem 10] together with Proposition 2 Point 2.

\(\square \)

Our main contribution in this paper is the following fact.

Theorem 10

Let \(\mathbf {A}\) be a finite n-element algebra and \(\mathcal {V}={{\textsf {V}}}(\mathbf {A})\). If \(\mathcal {V}\) is ASC, then \(\mathcal {V}\) is residually \(\left( n^{(n+1)\cdot n^{2\cdot n}}+1\right) \)-bounded. If there is a constant in the language, then \(\mathcal {V}\) is residually \(\left( n^{2\cdot n^2}+1\right) \)-bounded.

Proof

Let \(\mathbf {M}\) be a subalgebra of \(\mathbf {F}_\mathcal {V}(1)\). Let us use Lemma 9 two times: when \(\mathcal {G}=\{\mathbf {A}\}\) and when \(\mathcal {G}=\mathcal {V}_{SI}\). The second case is justified by Proposition 1 Point 3. We obtain that

figure g

Let us now consider an algebra \(\mathbf {S}\in \mathcal {V}_{SI}\). Our aim is to find a bound on the cardinality of S. Assume that the least nontrivial congruence on \(\mathbf {S}\) is generated by a pair (rs). For \(a,b\in M\) let \(\theta _{a,b}\) be a maximal \({\textsf {Q}}(\mathbf {A}\times \mathbf {M})\)-congruence on \(\mathbf {S}\times \mathbf {M}\) such \(((r,a),(s,b))\not \in \theta _{a,b}\). The existence of \(\theta _{a,b}\) follows from Zorn’s Lemma, the fact that a union of a chain of \({\textsf {Q}}(\mathbf {A}\times \mathbf {M})\)-congruences is a \({\textsf {Q}}(\mathbf {A}\times \mathbf {M})\)-congruence and, most importantly, the fact that there exists at least one \({\textsf {Q}}(\mathbf {A}\times \mathbf {M})\)-congruence on \(\mathbf {S}\times \mathbf {M}\) not containing ((ra), (sb)), namely the identity relation. This follows from (\(*\)). Let

$$\begin{aligned} \pi =\{((p,a),(p,b)) : p\in S \text { and } a,b\in M\}. \end{aligned}$$

The relation \(\pi \) is the kernel of the projection on the first coordinate of \(\mathbf {S}\times \mathbf {M}\).

We claim that

$$\begin{aligned} \bigcap _{a,b\in M} \theta _{a,b}\subseteq \pi . \end{aligned}$$

Indeed, assume that \(((p,c),(q,d))\in \theta _{a,b}\) for some distinct \(p,q\in S\). Then (rs) is in the congruence of \(\mathbf {S}\) generated by (pq). Let us consider Mal’cev’s scheme witnessing it [5, Theorem V.3.3]. It is given by terms \(t_0(x,\bar{y}),\ldots ,t_l(x,\bar{y})\), elements \(u_0,v_0,\ldots , u_l,v_l\in \{p,q\}\), and a tuple \(\bar{w}\) of elements of S such that in \(\mathbf {S}\) we have

$$\begin{aligned} r=t_0(u_0,\bar{w})\,\quad s=t_l(v_l,\bar{w}),\quad t_i(v_i,\bar{w})=t_{i+1}(u_{i+1},\bar{w})\quad \text { for all }i<l. \end{aligned}$$

Let \(\bar{g}\) be an arbitrary tuple of elements of M of the same lenght as \(\bar{w}\). Let

$$\begin{aligned} e= {\left\{ \begin{array}{ll} t_0(c,\bar{g})&{}\text { if } u_0=p\\ t_0(d,\bar{g})&{}\text { if } u_0=q \end{array}\right. } ,\quad f= {\left\{ \begin{array}{ll} t_l(c,\bar{g})&{}\text { if } v_l=p\\ t_l(d,\bar{g})&{}\text { if } v_l=q \end{array}\right. }. \end{aligned}$$

Then, ((re), (sf)) is in the congruence on \(\mathbf {S}\times \mathbf {M}\) generated by ((pc), (qd)). Since \(((r,e),(s,f))\not \in \theta _{e,f}\), we have \(((p,c),(q,d))\not \in \theta _{e,f}\). This establishes the claim.

We conclude that there is a surjective homomorphism

$$\begin{aligned} \mathbf {S}\times \mathbf {M}/\bigcap _{a,b\in M}\theta _{a,b} \rightarrow \mathbf {S}. \end{aligned}$$

This yields that

$$\begin{aligned} |S|\le |S\times M/\bigcap _{a,b\in M}\theta _{a,b}|. \end{aligned}$$

Moreover, \(\mathbf {S}\times \mathbf {M}/\bigcap \theta _{a,b}\) embeds into \(\prod \mathbf {S}\times \mathbf {M}/\theta _{a,b}\). Thus

$$\begin{aligned} |S\times M/\bigcap _{a,b\in M}\theta _{a,b}| \le \prod _{a,b\in M} |S\times M/\theta _{a,b\in M}|. \end{aligned}$$

Further, Since every algebra \(\mathbf {S}\times \mathbf {M}/\theta _{a,b}\) is \({\textsf {Q}}(\mathbf {A}\times \mathbf {M})\)-subdirectly irreducible, by Proposition 1 Point 5, \(\mathbf {S}\times \mathbf {M}/\theta _{a,b}\) embeds into \(\mathbf {A}\times \mathbf {M}\). In particular,

$$\begin{aligned} |S\times M/\theta _{a,b}|\le |A|\cdot |M|. \end{aligned}$$

Combining all these facts, we obtain that

$$\begin{aligned} |S|\le (|A|\cdot |M|)^{|M|^2}= |A|^{|M|^2}\cdot |M|^{|M|^2} \end{aligned}$$

If we have a constant in the language, we may take \(\mathbf {M}=\mathbf {F}_\mathcal {V}(0)\). Then, by Proposition 2 Point 2, \(|M|\le |A|=n\) and

$$\begin{aligned} |S|\le n^{2\cdot n^2}. \end{aligned}$$

In general, as \(\mathbf {M}\) we may take a subalgebra of \(\mathbf {F}_\mathcal {V}(1)\). Then, also by Proposition 2 Point 2, \(|M|\le n^{n}\). Thus

$$\begin{aligned} |S|\le n^{(n+1)\cdot n^{2\cdot n}}. \end{aligned}$$

\(\square \)

5 A partial solution to the (A)SC-problem for varieties

By the RES-problem we mean the following computational problem

figure h

Proposition 11

Let \(\mathcal {C}\) be a set of finite algebras.Footnote 2 If the exists an algorithm solving the RES-problem when the input algebra is from \(\mathcal {C}\), then there is an algorithm solving the (A)SC-problem for varieties when the input algebra is from \(\mathcal {C}\).

Proof

Assume that the exists an algorithm Res answering to the question in the RES-problem when the input algebra is in \(\mathcal {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 \(\mathcal {V}\) with a finite residual bound, let \(\mathcal {V}_{SI}^i\) be a class which consists of one representative from each isomorphism class contained in \(\mathcal {V}_{SI}\). 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 \(\mathcal {C}\).

figure i
figure j

\(\square \)

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 \(\mathcal {V}\) is congruence meet-semidistributive if for every \(\mathbf {A}\in \mathcal {V}\) the congruence lattice \({{\,\mathrm{Con}\,}}(\mathbf {A})\) satisfies the following quasi-identity

$$\begin{aligned} (\forall \alpha ,\beta ,\gamma )\;\alpha \wedge \beta \approx \alpha \wedge \gamma \rightarrow \alpha \wedge \gamma \approx \alpha \wedge (\beta \vee \gamma ). \end{aligned}$$

As an example, note that if \(\mathbf {B}\) has a semilattice term operation, then \({\textsf {V}}(\mathbf {B})\) is congruence meet-semidistributive [39]. A variety \(\mathcal {V}\) is congruence modular if for every \(\mathbf {A}\) the congrunece lattice \({{\,\mathrm{Con}\,}}(\mathbf {A})\) satisfies the following quasi-identity

$$\begin{aligned} (\forall \alpha ,\beta ,\gamma )\;\alpha \wedge \beta \approx \beta \rightarrow \alpha \wedge (\beta \vee \gamma )\approx \beta \vee (\alpha \wedge \gamma ). \end{aligned}$$

As an example, note that if \(\mathbf {B}\) has a Mal’cev term, i.e., a term t(xyz) such that \(\mathbf {B}\models (\forall x,y,z)\; t(x,y,y)\approx t(y,y,x)\approx x\), then \({\textsf {V}}(\mathbf {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 \(\mathbf{L}\), \(\mathbf{R}\) and \(\mathbf{N}\) be two-element semigroups satisfying the respective identities \((\forall x,y)\, x y\approx x\), \((\forall x,y)\, x y\approx y\) and \((\forall x,y,u,v)\, x y \approx u v\). Let \(\mathbf{I}\) be a two-element semilattice. Let \(\mathbf P\) (\(\mathbf{Q}\)) be the semigroup with the carrier \(\{e,u,0\}\) satisfying \(e^2=e\), \(e u=u\) (\(u e=u\)) and \(x y=0\) in the other cases. A semigroup \(\mathbf {G}\) is a group if it has a neutral element e and for every \(a\in G\) there exists an element \(b\in G\) such that \(ab=ba=e\). And is a group of exponentp if for every \(a\in G\), \(a^p=e\). Let \(\mathbf {A}\) be a finite semigroup. Then \(\mathbf {A}\models (\forall x)\, x^{i+p} \approx 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 \(\mathcal {V}={{\textsf {V}}}(\mathbf {A})\) is a group of exponent p. It follows that the class of all groups in \(\mathcal {V}\) forms a variety. Let us denote it by \(\mathcal {V}^g\). Let \(\mathbf {A}^g\) be the product of all maximal subsemigroups of \(\mathbf {A}\) which are groups. Let \(\mathbb {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 \(\mathbf {A}\) be a finite semigroup. Then \({{\textsf {V}}}(\mathbf {A})\) is residually bounded by a finite number if and only if one of the conditions holds

  1. 1.

    \(\mathbf {A}\in {{\textsf {V}}}(\mathbf{L}\times \mathbf{R}\times \mathbf{N}\times \mathbf{I}\times \mathbf {A}^g)\) and all Sylow subgroups of \(\mathbf {A}^g\) are abelian;

  2. 2.

    \(\mathbf {A}\in {{\textsf {V}}}(\mathbf{L}\times \mathbf{P}\times {\mathbb {Z}}_{p})\), where \(p= |A|!\);

  3. 3.

    \(\mathbf {A}\in {{\textsf {V}}}(\mathbf{R}\times \mathbf{Q}\times {\mathbb {Z}}_{p})\), where \(p= |A|!\).

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 \(\mathcal {V}={{\textsf {V}}}(\mathbf {A})\) has a finite residual bound. Then, again, by the main theorem in [19], there are three cases to consider: (1) Either \(\mathcal {V}= {{\textsf {V}}}({\mathcal {K}}\cup \{\mathbf{G}\})\), where \(\mathcal {K}\subseteq \{\mathbf{L},\mathbf{R}, \mathbf{N}, \mathbf{I}\}\) and \(\mathbf G\) is a group with all Sylow subgroups abelian. As \(\mathbf{G}\in \mathcal {V}\), \(\mathbf{G}\in \mathcal {V}^g\). By [26, Theorem 1 and Lemma 28], \(\mathcal {V}^g={{\textsf {V}}}(\mathbf {A}^g)\). Hence \(\mathbf {A}\in {{\textsf {V}}}(\mathbf{L}\times \mathbf{R}\times \mathbf{N}\times \mathbf{I}\times \mathbf {A}^g)\). Moreover, \(\mathcal {V}^g\) is also finitely residually bounded. Thus, by [31, Lemma 1], all Sylow subgroups of \(\mathbf {A}^g\) are abelian. (2) Or \(\mathcal {V}= {{\textsf {V}}}(\mathcal {K}\cup \{\mathbf {C}\})\), where \(\mathcal {K}\subseteq \{\mathbf{L},\mathbf{P}\}\) and \(\mathbf {C}\) is a finite cyclic group. As \(\mathbf {C}\in \mathcal {V}^g\), \(\mathbf {C}\in \textsf {H}({\mathbb {Z}}_p)\). (3) Or \(\mathcal {V}= {{\textsf {V}}}(\mathcal {K}\cup \{\mathbf {C}\})\), where \(\mathcal {K}\subseteq \{\mathbf{R},\mathbf{Q}\}\) and \(\mathbf {C}\) is a finite cyclic group. In this case we may also infer that \(\mathbf {C}\in \textsf {H}({\mathbb {Z}}_p)\). \(\square \)

Corollary 13

There are algorithms solving the \({\mathrm{RES}}\)-problem when the input algebras are from one of the following sets:

  1. 1.

    the set of finite algebras generating congruence meet-semidistributive varieties;

  2. 2.

    the set of finite algebras generating congruence modular varieties;

  3. 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 \(\mathcal {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_{\mathcal {C}}\) such that for every algebra \(\mathbf {A}\in \mathcal {C}\) either \({\textsf {V}}(\mathbf {A})\) is not residually m-bounded for every \(m\in \mathbb {N}\), or \({\textsf {V}}(\mathbf {A})\) is residually \(n_{\mathcal {C}}(\mathbf {A})\)-bounded, and it is decidable which case holds. Thus we have the following algorithm.

figure k

(Recall that \({{\textsf {V}}}(\mathbf {A})^i_{SI}\) consists of one representative from each isomorphism class contained in \({{\textsf {V}}}(\mathbf {A})_{SI}\).)

Let us review results from the literature for specific classes of algebras.

  1. (1)

    It was proved by Willard in [39, Corollary 5.2]. The function \(n_{\mathcal {C}}\) is given in [39, Theorem 5.1].

  2. (2)

    Freese and McKenzie proved in [17, Theorem 8] that if \(\mathcal {C}\) is the set of finite algebras generating congruence modular varieties, then as \(n_{\mathcal {C}}(\mathbf {A})\) one may take the value \(({|A|}^{{|A|}^{{|A|}+1}}+1)!\cdot |A|+1\). Moreover, \({\textsf {V}}(\mathbf {A})\) is residually \(n_{\mathcal {C}}(\mathbf {A})\)-bounded iff for all congruences \(\alpha ,\beta \) of any subalgebra of \(\mathbf {A}\), \(\alpha \le [\beta ,\beta ]\) implies \(\alpha =[\beta ,\alpha ]\) (\([\;\,,\,\;]\) is the commutator operation). This condition is decidable.

  3. (3)

    By Theorem 12, we may decide whether a finite semigroup \(\mathbf {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 \({{\textsf {V}}}(\mathbf {A})\) are smaller than \(2\cdot |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 \({{\textsf {V}}}(\mathbf {A})^g_{SI}\), in the first case. As \({{\textsf {V}}}(\mathbf {A})^g\) is congruence modular, r may be computed as in the previous point of this theorem.

\(\square \)

Corollary 13 gives examples of prominent sets of finite algebras \(\mathcal {C}\) such that the exist algorithms solving the the RES-problem when the input algebra is in \(\mathcal {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:\mathbb {N}\rightarrow \mathbb {N}\) be a computable function. Let us consider the following problem.

figure l

By Proposition 8, the decidability of \(\hbox {RES}{}_f\) for \(f(n)=n+1\) yields the decidability of the SC-problem for varieties. Similarly, by Theorem 10, the decidability of \(\hbox {RES}{}_f\) for \(f(n)=n^{(n+1)\cdot n^{2\cdot n}}+1\) yields the decidability of the ASC-problem and the SC-problem for varieties.

Question 3

Let \(f:{\mathbb {N}}\rightarrow {\mathbb {N}}\) be a computable function. Does there exist an algorithm solving the Res\({}_f\)-problem?