Miguel Couceiro

Jimmy Devillet

Jean-Luc Marichal

QUASITRIVIAL SEMIGROUPS: CHARACTERIZATIONS AND ENUMERATIONS

Keywords: January 15, 2018. 2010 Mathematics Subject Classification. Primary 05A15, 20M14, 20M99; Secondary 39B72 Quasitrivial semigroup, quasitrivial and commutative semigroup, quasitrivial and order-preserving semigroup, enumeration of quasitrivial semigroups, single-peaked ordering, single-plateaued weak ordering

come

INTRODUCTION

Let X be an arbitrary nonempty set. We use the symbol X n if X contains n ≥ 1 elements, in which case we assume w.l.o.g. that X n = {1, . . . , n}.

In this paper we investigate the class of binary operations F ∶ X 2 → X that are associative and quasitrivial, where quasitriviality means that F always outputs one of its input values. In the algebraic language, the pair (X, F ) is then called a quasitrivial semigroup (for general background, see, e.g., [START_REF] Ježek | Quasitrivial and nearly quasitrivial distributive groupoids and semigroups[END_REF][START_REF] Kepka | Quasitrivial groupoids and balanced identities[END_REF][START_REF] Länger | The free algebra in the variety generated by quasi-trivial semigroups[END_REF] and for a recent reference, see [START_REF] Ackerman | A characterization of quasitrivial n-semigroups[END_REF]). We also investigate certain subclasses of quasitrivial semigroups by adding properties such as commutativity, order-preservation, and the existence of neutral elements. The case where the semigroups are defined on finite sets (i.e., X = X n for any integer n ≥ 1) is of particular interest as it enables us to address and solve various enumeration issues. We remark that most of our results rely on a simple known theorem (Theorem 2.1) that provides a descriptive characterization of the class of quasitrivial semigroups.

After presenting some definitions and preliminary results (including Theorem 2.1) in Section 2, we provide in Section 3 different characterizations of the class of quasitrivial and commutative (i.e., Abelian) semigroups on both arbitrary sets and finite sets (Theorem 3.3). In the latter case we illustrate some of our results by showing the contour plots of the operations. When X is endowed with a total ordering we also characterize the subclass of quasitrivial, commutative, and order-preserving semigroups (Theorem 3.7) by means of the single-peakedness property, which is a generalization to arbitrary totally ordered sets of a notion introduced 70 years ago in social choice theory. In Section 4 we introduce the "weak single-peakedness" property (Definition 4.3) as a further generalization of single-peakedness to arbitrary weakly ordered sets to characterize the class of quasitrivial and order-preserving semigroups (Theorem 4.5). In the special case where the semigroups are defined on finite sets, the class of quasitrivial semigroups is also finite. This raises the problem of computing the size of this class as well as the sizes of all subclasses discussed in this paper. We tackle this problem in Section 4 where we arrive at some known integer sequences as well as new ones. The number of quasitrivial semigroups on X n for any integer n ≥ 1 (Theorem 4.1) gives rise to a sequence that was previously unknown in the Sloane's On-Line Encyclopedia of Integer Sequences (OEIS, see [START_REF]The On-Line Encyclopedia of Integer Sequences[END_REF]). All the (old and new) sequences that we consider are given in explicit forms (i.e., closed-form expressions) and/or through their generating functions or exponential generating functions (Theorem 4.1 and Propositions 4.2, 4.8, 4.9, 4.11, and 4.12). In Section 5 we further investigate the single-peakedness and weak single-peakedness properties and provide a graphical characterization of weakly single-peaked weak orderings (Theorem 5.6). We also observe that the weakly single-peaked weak orderings on X n are precisely the so-called single-plateaued weak orderings introduced in social choice theory.

PRELIMINARIES

Recall that a binary relation R on X is said to be Note that any total binary relation R on X is reflexive, i.e., xRx for all x ∈ X.

Recall also that a total ordering on X is a binary relation ≤ on X that is total, transitive, and antisymmetric. More generally, a weak ordering on X is a binary relation ≲ on X that is total and transitive. We denote the symmetric and asymmetric parts of ≲ by ∼ and <, respectively. Thus, x ∼ y means that x ≲ y and y ≲ x. Also, x < y means that x ≲ y and ¬(y ≲ x). Recall that ∼ is an equivalence relation on X and that < induces a total ordering on the quotient set X/ ∼. Thus, defining a weak ordering on X amounts to defining an ordered partition of X. For any a ∈ X, we use the notation [a] ∼ to denote the equivalence class of a, i.e., [a] ∼ = {x ∈ X ∶ x ∼ a}.

For any total ordering ≤ on X, the pair (X, ≤) is called a totally ordered set or a chain. Similarly, for any weak ordering ≲ on X, the pair (X, ≲) is called a weakly ordered set. For any integer n ≥ 1, we assume w.l.o.g. that the pair (X n , ≤ n ) represents the set X n = {1, . . . , n} endowed with the total ordering relation ≤ n defined by 1 < n ⋯ < n n.

If (X, ≲) is a weakly ordered set, an element a ∈ X is said to be maximal (resp. minimal) for ≲ if x ≲ a (resp. a ≲ x) for all x ∈ X. We denote the set of maximal (resp. minimal) elements of X for ≲ by max ≲ X (resp. min ≲ X). Note that this set need not be nonempty (consider, e.g., the set of nonnegative integers endowed with the usual total ordering ≤).

An operation F ∶ X 2 → X is said to be

• associative if F (F (x, y), z) = F (x, F (y, z)) for all x, y, z ∈ X; • idempotent if F (x, x) = x for all x ∈ X; • quasitrivial (or conservative) if F (x, y) ∈ {x, y} for all x, y ∈ X; • commutative if F (x, y) = F (y, x) for all x, y ∈ X;
• ≤-preserving for some total ordering ≤ on X if for any x, y, x ′ , y ′ ∈ X such that x ≤ x ′ and y ≤ y ′ , we have F (x, y) ≤ F (x ′ , y ′ ).

Given a weak ordering ≲ on X, the maximum (resp. minimum) operation on X w.r.t. ≲ is the commutative operation max ≲ (resp. min ≲ ) defined on X 2 ∖{(x, y) ∈ X 2 ∶ x ∼ y, x ≠ y} by max ≲ (x, y) = y (resp. min ≲ (x, y) = x) whenever x ≲ y. We observe that if ≲ reduces to a total ordering, then the operation max ≲ (resp. min ≲ ) is defined everywhere on X 2 . Also, the projection operations π 1 ∶ X 2 → X and π 2 ∶ X 2 → X (also called left-and right-semigroups) are respectively defined by π 1 (x, y) = x and π 2 (x, y) = y for all x, y ∈ X.

An element e ∈ X is said to be a neutral element

of F ∶ X 2 → X if F (x, e) = F (e, x) = x for all x ∈ X. An element a ∈ X is said to be an annihilator element of F ∶ X 2 → X if F (x, a) = F (a, x) = a for all x ∈ X.
For any integer n ≥ 1, any F ∶ X 2 n → X n , and any z ∈ X n , the F -degree of z, denoted deg F (z), is the number of points (x, y) ∈ X 2 n ∖ {(z, z)} such that F (x, y) = F (z, z). Also, the degree sequence of F , denoted deg F , is the nondecreasing n-element sequence of the numbers deg F (x), x ∈ X n .

We now state the key theorem on which most of our results rely. It provides a descriptive characterization of the class of associative and quasitrivial operations on X. As observed by Ackerman [1, Section 1.2], this result is a simple consequence of two papers on idempotent semigroups (see Kimura [START_REF] Kimura | The structure od idempotent semigroups[END_REF] and McLean [START_REF] Mclean | Idempotent semigroups[END_REF]). It was also independently presented by various authors (see, e.g., Kepka [START_REF] Kepka | Quasitrivial groupoids and balanced identities[END_REF]Corollary 1.6] and Länger [START_REF] Länger | The free algebra in the variety generated by quasi-trivial semigroups[END_REF]Theorem 1]). For the sake of completeness we provide a direct elementary proof.

Theorem 2.1. F ∶ X 2 → X is associative and quasitrivial iff there exists a weak ordering ≾ on X such that

(1) F | A×B = ⎧ ⎪ ⎪ ⎨ ⎪ ⎪ ⎩ max ≾ | A×B , if A ≠ B, π 1 | A×B or π 2 | A×B , if A = B, ∀A, B ∈ X/ ∼.
Proof. (Sufficiency) Trivial.

(Necessity) We observe that the binary relation ≾ defined on X as

(2) x ≾ y ⇔ F (x, y) = y or F (y, x) = y, x, y ∈ X,
is a weak ordering on X. Indeed, this relation is clearly total. Let us show that it is transitive. Let x, y, z ∈ X be pairwise distinct and such that x ≾ y and y ≾ z. Let us assume for instance that F (x, y) = y and F (z, y) = z (the other three cases can be dealt with similarly). Then we have F (x, z) = z and hence x ≾ z. Indeed, otherwise we would have

x = F (x, z) = F (x, F (z, y)) = F (F (x, z), y) = F (x, y) = y, a contradiction.
Let us now show that Eq. ( 1) holds. It is easy to see that for any x, y ∈ X such that x ≺ y, we have

F | {x,y} 2 = max ≾ | {x,y} 2 . Similarly, for any distinct x, y ∈ X such that x ∼ y we have F | {x,y} 2 = π 1 | {x,y} 2 or F | {x,y} 2 = π 2 | {x,y} 2 . Finally, let us show that for any pairwise distinct x, y, z ∈ X such that x ∼ y ∼ z, we cannot have both F | {x,y} 2 = π 1 | {x,y} 2 and F | {x,z} 2 = π 2 | {x,z} 2 . Indeed, otherwise • if F (y, z) = y, then z = F (x, z) = F (F (x, y), z) = F (x, F (y, z)) = F (x, y) = x, • if F (y, z) = z, then y = F (y, x) = F (y, F (z, x)) = F (F (y, z), x) = F (z, x) = x.
We reach a contradiction in each of these cases.

It is not difficult to see that the weak ordering ≾ mentioned in Theorem 2.1 is uniquely determined from F and can be defined by condition [START_REF] Berg | Single-peaked compatible preference profiles: some combinatorial results[END_REF]. If X = X n for some integer n ≥ 1, then ≾ can be as well defined as follows: x ≾ y iff deg F (x) ≤ deg F (y). 1 This latter equivalence can be easily derived (see Corollary 2.3) from the following proposition.

Proposition 2.2. If F ∶ X 2 n → X n is of the form (1)
for some weak ordering ≾ on X n , then for any x ∈ X n , we have

deg F (x) = 2 × |{z ∈ X n ∶ z ≺ x}| + |{z ∈ X n ∶ z ∼ x, z ≠ x}| = |{z ∈ X n ∶ z ≺ x}| + |{z ∈ X n ∶ z ≾ x}| -1.
Proof. Let x ∈ X n . By quasitriviality, only points of the form (x, z) or (z, x) for some z ∈ X n may have the same value as (x, x).

•

If z ≺ x, then F (x, z) = F (z, x) = x = F (x, x). • If x ≺ z, then F (x, z) = F (z, x) = z ≠ F (x, x). • If z ∼ x and z ≠ x, then either F (x, z) = π 1 (x, z) or F (x, z) = π 2 (x, z). In the first case, we have F (x, z) = x = F (x, x) ≠ z = F (z, x).
The other case is similar. This completes the proof of Proposition 2.2.

Corollary 2.3. If F ∶ X 2 n → X n is of the form (1)
for some weak ordering ≾ on X n , then for any x, y ∈ X n , we have

x ≾ y ⇔ deg F (x) ≤ deg F (y). Proof. Let x, y ∈ X n such that x ≾ y. We clearly have |{z ∈ X n ∶ z ≺ x}| ≤ |{z ∈ X n ∶ z ≺ y}| and |{z ∈ X n ∶ z ≾ x}| ≤ |{z ∈ X n ∶ z ≾ y}|.
By Proposition 2.2, we then immediately have deg F (x) ≤ deg F (y). The (contrapositive of the) reverse implication can be proved similarly.

From the properties of the maximum operation in (1), we can observe the following fact.

Fact 2.4. If F ∶ X 2 → X is of the form (1)
for some weak ordering ≾ on X, then F has a neutral element e ∈ X (resp. an annihilator element a ∈ X) iff the weakly ordered set (X, ≾) has a unique minimal element denoted by x (resp. a unique maximal element denoted by x ⊺ ). In this case we have e = x (resp. a = x ⊺ ). Remark 1. If F ∶ X 2 → X is of the form (1) for some weak ordering ≾ on X, then, by replacing ≾ with its inverse relation ≾ -1 (defined by a ≾ -1 b ⇔ b ≾ a), we see that F is again of the form (1), except that the maximum operation is changed to the minimum operation. Thus, choosing the maximum or the minimum operation is just a matter of convention.

The following lemma can be obtained by following the first few steps of the proof of [6, Theorem 3], which was stated in the special case where X is an arbitrary closed real interval. For the sake of self-containedness we provide a short proof. Lemma 2.5 (see [START_REF] Czogała | Associative monotonic operations in fuzzy set theory[END_REF]Theorem 3]). If F ∶ X 2 → X is associative, idempotent, ≤-preserving for some total ordering ≤ on X, and has a neutral element, then F is quasitrivial.

Proof. Let min∶ X 2 → X and max∶ X 2 → X denote respectively the minimum and maximum operations w.r.t. ≤ and let e denote the neutral element of F . By idempotency and ≤-preservation we clearly have min(x, y) ≤ F (x, y) ≤ max(x, y),

x, y ∈ X.

If x, y ≤ e, then by ≤-preservation we obtain F (x, y) ≤ min(F (x, e), F (e, y)) = min(x, y). Thus F (x, y) = min(x, y) whenever x, y ≤ e. We show dually that F (x, y) = max(x, y) whenever x, y ≥ e. Assume now that x < e < y (the case y < e < x can be dealt with dually).

If F (x, y) ≤ e, then F (x, y) = F (F (x, x), y) = F (x, F (x, y)) = min(x, F (x, y)) = x. We prove similarly that F (x, y) = y whenever F (x, y) ≥ e. It follows that F is quasitrivial.

When X n is endowed with ≤ n , the operations F ∶ X 2 n → X n can be visualized through their contour plots, where we connect points in X 2 n having the same F -values by edges or paths. For instance, the operation F ∶ X 2 6 → X 6 whose contour plot is shown in Figure 1 is associative, quasitrivial, commutative, and ≤ 6 -preserving. n are said to be F -connected if they have the same F -value, i.e., if F (x, y) = F (u, v). Using this definition, we can state the following four graphical tests (see [START_REF] Couceiro | Characterizations of idempotent discrete uninorms[END_REF]), where F ∶ X 2 n → X n denotes an arbitrary operation and ∆ Xn denotes the set {(x, x) ∶ x ∈ X n }.

• F is quasitrivial iff it is idempotent and every point (x, y) ∈ X 2 n ∖ ∆ Xn is Fconnected to either (x, x) or (y, y).

• If F is quasitrivial, then e ∈ X is a neutral element of F iff the point (e, e) is not F -connected to another point, i.e., iff deg F (e) = 0.

• If F is quasitrivial, then a ∈ X is an annihilator element of F iff the point (a, a)
is F -connected to exactly 2n -2 points, i.e., iff deg F (a) = 2n -2. • If F is quasitrivial, then it is associative iff for every rectangle in X 2 n that has only one vertex on ∆ Xn , at least two of the remaining three vertices are F -connected.

QUASITRIVIAL AND COMMUTATIVE SEMIGROUPS

In this section we provide characterizations of the class of associative, quasitrivial, and commutative operations F ∶ X 2 → X, or equivalently, the class of quasitrivial and commutative semigroups on X. We also characterize the subclass of those operations that are order-preserving with respect to some total ordering on X.

The first characterization is given in the following theorem, which immediately follows from Theorem 2.1. We observe that Ackerman (see [START_REF] Ackerman | A characterization of quasitrivial n-semigroups[END_REF]Corollary 4.10]) generalized this result to n-ary semigroups for any integer n ≥ 2.

Theorem 3.1. F ∶ X 2 → X is associative, quasitrivial, and commutative iff there exists a total ordering ⪯ on X such that F = max ⪯ . Theorem 3.3 below provides alternative characterizations of the class of associative, quasitrivial, and commutative operations. We first consider the following auxiliary lemma. Lemma 3.2. If F ∶ X 2 → X is quasitrivial, commutative, ≤-preserving for some total ordering ≤ on X, then F is associative.

Proof. This result was established in the special case where X is the real unit interval [0, 1] in [17, Proposition 2]. The proof therein is purely algebraic and hence it applies to any nonempty totally ordered set. Theorem 3.3. Let F ∶ X 2 → X be an operation. The following assertions are equivalent.

(i) F is associative, quasitrivial, and commutative.

(ii) F = max ⪯ for some total ordering ⪯ on X.

(iii) F is quasitrivial, commutative, and ≤-preserving for some total ordering ≤ on X. If X = X n for some integer n ≥ 1, then any of the assertions (i)-(iii) above is equivalent to any of the following ones.

(iv) F is quasitrivial and satisfies deg F = (0, 2, 4, . . . , 2n -2).

(v) F is associative, idempotent, commutative, ≤-preserving for some total ordering ≤ on X, and has a neutral element. Moreover, there are exactly n! operations F ∶ X 2 n → X n satisfying any of the assertions (i)-(v). Furthermore, the total ordering ⪯ considered in assertion (ii) is uniquely defined as follows:

x ⪯ y iff deg F (x) ≤ deg F (y).
In particular, each of these operations has the (unique) neutral element e = min ⪯ X n and the (unique) annihilator element a = max ⪯ X n .

Proof. The equivalence (i) ⇔ (ii) ⇔ (iii) follows from Theorem 3.1 and Lemma 3.2. We have (ii) ⇒ (v) by Fact 2.4 and (v) ⇒ (iii) by Lemma 2.5. Also, it is clear that (ii) ⇒ (iv).

Let us now show by induction on n that (iv) ⇒ (ii). The result clearly holds for n = 1. Suppose that it holds for some n ≥ 1 and let us show that it still holds for n + 1. 2 is quasitrivial and such that deg F ′ = (0, 2, . . . , 2n -2). By induction hypothesis we have

Assume that F ∶ X 2 n+1 → X n+1 is quasitrivial and that deg F = (0, 2, . . . , 2n). Let ⪯ be the unique total ordering on X n+1 defined by x ⪯ y iff deg F (x) ≤ deg F (y) and let z = max ⪯ X n+1 . Clearly, the operation F ′ = F | (Xn+1∖{z})
F ′ = max ⪯ ′ , where ⪯ ′ is the restriction of ⪯ to (X n+1 ∖ {z}) 2 . Since deg F (z) = 2n we necessarily have F = max ⪯ .
To complete the proof of the theorem, we observe that there are exactly n! total orderings on X n and hence exactly n! operations F ∶ X 2 n → X n satisfying assertion (ii). The rest of the statement is immediate.

Remark 2. The existence of a neutral element in assertion (v) of Theorem 3.3 cannot be replaced with the existence of an annihilator element. Indeed, the operation F ∶ X 2 3 → X 3 whose contour plot is depicted in Figure 2 is associative, idempotent, commutative, ≤ 3preserving, and has the annihilator element a = 2. However it is not quasitrivial. We now consider the subclass of associative, quasitrivial, and commutative operations F ∶ X 2 → X that are ≤-preserving for some fixed total ordering ≤ on X. To this extent we recall the single-peakedness property for arbitrary totally ordered sets. This notion was first introduced for finite totally ordered sets (i.e., finite chains) in social choice theory by Black [START_REF] Black | On the rationale of group decision-making[END_REF][START_REF] Black | The theory of committees and elections[END_REF]. Definition 3.4 (see [START_REF] Devillet | Characterizations of quasitrivial symmetric nondecreasing associative operations[END_REF]Definition 3.8]). Let ≤ and ⪯ be total orderings on X. We say that ⪯ is single-peaked w.r.t. ≤ if for any a, b, c ∈ X such that a < b < c, we have b ≺ a or b ≺ c. Example 3.5. There are four total orderings ⪯ on X 3 that are single-peaked w.r.t. and3 ≺ 2 ≺ 1. For arbitrary total orderings ≤ and ⪯ on X, the operation F = max ⪯ need not be ≤preserving. The following proposition characterizes those total orderings ⪯ on X for which F = max ⪯ is ≤-preserving. Proposition 3.6 (see [START_REF] Devillet | Characterizations of quasitrivial symmetric nondecreasing associative operations[END_REF]Proposition 3.9]). Let ≤ be a total ordering on X and let F ∶ X 2 → X be given by F = max ⪯ for some total ordering ⪯ on X.

≤ 3 , namely 1 ≺ 2 ≺ 3, 2 ≺ 1 ≺ 3, 2 ≺ 3 ≺ 1,
Then F is ≤-preserving iff ⪯ is single-peaked w.r.t. ≤.
The following theorem is an immediate consequence of Lemma 3.2, Theorem 3.3, Proposition 3.6 and the known fact (see also Section 5) that there are exactly 2 n-1 total orderings on X n that are single-peaked w.r.t. ≤ n .

Theorem 3.7. Let F ∶ X 2 → X be an operation and let ≤ be a total ordering on X. The following assertions are equivalent.

(i) F is quasitrivial, commutative, and ≤-preserving.

(ii) F = max ⪯ for some total ordering ⪯ on X that is single-peaked w.r.t. ≤. If (X, ≤) = (X n , ≤ n ) for some integer n ≥ 1,

then any of the assertions (i)-(ii) above is equivalent to any of the following ones.

(iii) F is quasitrivial, ≤-preserving, and satisfies deg F = (0, 2, 4, . . . , 2n -2).

(iv) F is associative, idempotent, commutative, ≤-preserving, and has a neutral element. Moreover, there are exactly 2 n-1 operations F ∶ X 2 n → X n satisfying any of the assertions (i)-(iv). Furthermore, the total ordering ⪯ considered in assertion (ii) is uniquely defined as follows: x ⪯ y iff deg F (x) ≤ deg F (y). In particular, each of these operations has the (unique) neutral element e = min ⪯ X n and the (unique) annihilator element a = max ⪯ X n .

Example 3.8. In Figure 3 we present the 3! = 6 associative, quasitrivial, and commutative operations on X 3 . Only the first 2 3-1 = 4 operations are ≤ 3 -preserving. All these operations have neutral and annihilator elements. (a) To better illustrate Theorem 3.7 when X is finite, consider the operation F ∶ X 2 6 → X 6 whose contour plot is shown in Figure 4 (left). This operation is clearly quasitrivial, ≤ 6 -preserving, and is such that deg F = (0, 2, . . . , 10).

By Theorem 3.7 we then have F = max ⪯ , where ⪯ is the total ordering on X 6 obtained by sorting the numbers deg F (x), x ∈ X 6 , in increasing order, that is,

4 ≺ 3 ≺ 5 ≺ 2 ≺ 1 ≺ 6; see

ENUMERATIONS OF ARBITRARY QUASITRIVIAL SEMIGROUPS

This section is devoted to the arbitrary associative and quasitrivial operations that need not be commutative. Recall that a characterization of this class of operations is given in Theorem 2.1. However, to our knowledge a generalization of Theorem 3.3 to noncommutative operations is not known and hence remains an open problem. On this issue we make the following two observations.

• An associative and quasitrivial operation F ∶ X 2 → X need not have a neutral element, even if X is finite. For instance, the projection operations π 1 and π 2 have no neutral element. • An associative and quasitrivial operation F ∶ X 2 → X need not be ≤-preserving for some total ordering ≤ on X, even if X is finite. To illustrate, consider F ∶ X 2 4 → X 4 whose contour plot is depicted in Figure 5. This operation is associative and quasitrivial. However, it can be shown that it is not ≤-preserving for any of the 24 total orderings ≤ on X 4 . r r r r r r r r r r r r r r r r ¤ ¥ FIGURE 5. An operation that is not ≤-preserving for any total ordering ≤ In the rest of this section, we consider the problem of enumerating quasitrivial semigroups on finite sets. For instance, for any integer n ≥ 1, we provide in Theorem 4.1 the exact number of associative and quasitrivial operations F ∶ X 2 n → X n . We posted the corresponding sequence in Sloane's On-Line Encyclopedia of Integer Sequences (OEIS, see [START_REF]The On-Line Encyclopedia of Integer Sequences[END_REF]) as sequence A292932.

In this section we often consider either the (ordinary) generating function (GF) or the exponential generating function (EGF) of a given integer sequence (s n ) n≥0 . Recall that, when these functions exist, they are respectively defined by the power series

S(z) = ∑ n≥0 s n z n and Ŝ(z) = ∑ n≥0 s n z n n! .
Recall also that for any integers 0 ≤ k ≤ n, the Stirling number of the second kind { n k } is defined by

{ n k } = 1 k! k ∑ i=0 (-1) k-i ( k i ) i n .
For any integer n ≥ 0, let p(n) denote the number of weak orderings on X n , or equivalently, the number of ordered partitions of X n . Setting p(0) = 1, the number p(n) is explicitly given by

p(n) = n ∑ k=0 { n k } k! , n ≥ 0.
Actually, the corresponding sequence (p(n)) n≥0 consists of the ordered Bell numbers (Sloane's A000670) and satisfies the following recurrence equation

p(n + 1) = n ∑ k=0 ( n + 1 k ) p(k) , n ≥ 0,
with p(0) = 1. Moreover, its EGF is given by P (z) = 1/(2 -e z ).

For any integer n ≥ 1, we denote by q(n) the number of associative and quasitrivial operations F ∶ X 2 n → X n (i.e., the number of quasitrivial semigroups on an n-element set). As a convention, we set q(0) = 1. Also, for any integer n ≥ 0, we denote by q e (n) (resp. q a (n), q ea (n)) the number of associative and quasitrivial operations F ∶ X 2 n → X n that have neutral elements (resp. annihilator elements, both neutral and annihilator elements). As a convention, we set q e (0) = q a (0) = q ea (0) = 0. Theorem 4.1 and Proposition 4.2 below provide explicit formulas for these sequences. The first few values of these sequences are shown in Table 1.

Theorem 4.1. For any integer n ≥ 0, we have the closed-form expression

(3) q(n) = n ∑ i=0 2 i n-i ∑ k=0 (-1) k ( n k ){ n -k i } (i + k)! , n ≥ 0.
Moreover, the sequence (q(n)) n≥0 satisfies the recurrence equation

q(n + 1) = (n + 1) q(n) + 2 n-1 ∑ k=0 ( n + 1 k ) q(k) , n ≥ 0,
with q(0) = 1. Furthermore, its EGF is given by Q

(z) = 1/(z + 3 -2e z ).
Proof. Using Theorem 2.1 we can easily see that

(4) q(n) = n ∑ k=1 ∑ n1,...,n k ≥1 n1+⋯+n k =n ( n n 1 , . . . , n k ) k ∏ i=1 ni≥2 2 , ∀n ≥ 1.
Indeed, to compute q(n) we need to consider all the ordered partitions of X n and count twice each equivalence class containing at least two elements (because two possible projections are to be considered for each such class). In Eq. ( 4), k represents the number of equivalence classes and n i represents the cardinality of the ith class.

For any integer k ≥ 1, define the sequence (s k n ) n≥0 as ( 5)

s k n = ∑ n1,...,n k ≥0 n1+⋯+n k =n ( n n 1 , . . . , n k ) k ∏ i=1 min{n i , 2}.
Thus defined, the sequence (s k n ) n≥0 is the k-fold binomial convolution of the sequence (min{n, 2}) n≥0 (for background on convolutions see, e.g., [16, Section 7.2.1]). Since the EGF of the latter sequence is clearly the function z ↦ 2e z -z -2, it follows that the EGF of the sequence

(s k n ) n≥0 is the function z ↦ (2e z -z -2) k , which means that (6) s k n = D n z (2e z -z -2) k | z=0
, where D z denotes the usual differential operator.

Using ( 4)-( 6), for any integer n ≥ 1, we then obtain

q(n) = n ∑ k=1 s k n = D n z 1 -(2e z -z -2) n+1 z + 3 -2e z | z=0 = D n z 1 z + 3 -2e z | z=0 .
Since q(0) = 1 by definition, we thus see that the EGF of the sequence (q(n)) n≥0 is given by Q

(z) = (z + 3 -2e z ) -1 .
Now, by taking the (n + 1)st derivative at z = 0 of both sides of the identity

(z + 3 -2 e z ) Q(z) = 1
(using the general Leibniz rule) we immediately derive the claimed recurrence equation for the sequence (q(n)) n≥0 .

Let us now establish Eq. (3). It is enough to show that the EGF of the sequence (q(n)) n≥0 defined by q(0) = 1 and

q(n) = n ∑ i=0 2 i n-i ∑ k=0 (-1) k ( n k ){ n -k i } (i + k)! , n ≥ 1, is exactly Q(z).
For any integer i ≥ 0, consider the sequences (f i n ) n≥0 and (g i n ) n≥0 defined by f i n = (-1) n (n+i)! and g i n = { n i }. Define also the sequence (h i n ) n≥0 by the binomial convolution of (f i n ) n≥0 and (g i n ) n≥0 , that is,

h i n = n ∑ k=0 ( n k )(-1) k (i + k)!{ n -k i }.
Observing that

{ n-k i } = 0 if n -k < i we see that (7) q(n) = n ∑ i=0 2 i h i n , n ≥ 0.
Let Fi (z), Ĝi (z), and Ĥi (z) be the EGFs of the sequences (f i n ) n≥0 , (g i n ) n≥0 , and (h i n ) n≥0 , respectively. It is known (see, e.g., [9, p. 335, p. 351]) that Fi (z) = i!(z + 1) -i-1 and Ĝi (z) = (e z -1) i /i!. We then have

Ĥi (z) = Fi (z) Ĝi (z) = (e z -1) i (z + 1) i+1 .
Since h i n = D n z Ĥi (z)| z=0 , using [START_REF] Devillet | Characterizations of quasitrivial symmetric nondecreasing associative operations[END_REF] we obtain

q(n) = D n z 1 -(2 e z -1 z+1 ) n+1 z + 3 -2e z | z=0 = D n z 1 z + 3 -2e z | z=0 = (D n z Q)(0).
This means that the EGF of (q(n)) n≥0 is given by Q(z). This completes the proof.

Remark 4.

(a) It is clear that the radius r of convergence of the series Q(z) is less than or equal to the closest singularity (≈ 0.583) to the origin of the real function x ↦ 1/(x + 3 -2e x ). We conjecture that r is given by the classical ratio test and corresponds exactly to that singularity. In mathematical terms, this amounts to proving (or disproving) that q(n + 1)

(n + 1) q(n) → 1 r ≈ 1.715 as n → ∞,
where r ≈ 0.583 is the unique positive zero of the real function x ↦ x + 3 -2e x . (b) In the proof of Theorem 4.1 we have established Eq. ( 3) by first searching for the explicit form of Q(z) from the definition of the sequence (q(n)) n≥0 . In the appendix we provide an alternative proof of (3) that does not make use of Q(z).

Proposition 4.2. For any integer n ≥ 0, we have q e (n) = q a (n) = n q(n -1) and q ea (n) = n(n -1) q(n -2).

Proof. Let us first show how we can construct an associative and quasitrivial operation F ∶ X 2 n → X n having a neutral element. There are n ways to choose the neutral element e in X n . Then we observe that the restriction of F to (X n ∖ {e}) 2 is still an associative and quasitrivial operation, so we have q(n -1) possible choices to construct this restriction. This shows that q e (n) = n q(n -1). Using the same reasoning, we also obtain q a (n) = n q(n -1) and q ea (n) = n(n -1) q(n -2). 1. First few values of q(n), q e (n), q a (n), and q ea (n)

n q(n) q e (n) q a (n) q ea (n) 0 1 0 0 0 1 1 1 1 0 2 4
We now consider the subclass of associative and quasitrivial operations F ∶ X 2 n → X n that are ≤ n -preserving. To this extent, we introduce a generalization of single-peakedness to weak orderings, that we call weak single-peakedness. This leads to a generalization of Proposition 3.6 to arbitrary quasitrivial semigroups (see Proposition 4.4). We will further elaborate on this concept in Section 5. Definition 4.3. Let ≤ be a total ordering on X and let ≾ be a weak ordering on X. We say that ≾ is weakly single-peaked w.r.t. ≤ if for any a, b, c ∈ X such that a < b < c, we have b ≺ a or b ≺ c or a ∼ b ∼ c. Proposition 4.4. Let ≤ be a total ordering on X and let ≾ be a weak ordering on X. Suppose that F ∶ X 2 → X is of the form (1). Then F is ≤-preserving iff ≾ is weakly singlepeaked w.r.t. ≤. The other two cases can be dealt with similarly.

•

If F | [b] 2 ∼ = π 1 | [b] 2 ∼ , then by ≤-preservation of F we have b = F (a, b) ≤ F (a, c) ≤ F (b, c) = b. • If F | [b] 2 ∼ = π 2 | [b] 2 ∼ , then by ≤-preservation of F we have b = F (b, a) ≤ F (c, a) ≤ F (c, b) = b.
In the first (resp. second) case we obtain F (a, c) = b (resp. F (c, a) = b), which contradicts quasitriviality.

(Sufficiency) We proceed by contradiction. Suppose that ≾ is weakly single-peaked w.r.t. ≤ and that F is not ≤-preserving. Then, for instance there exist x, y, z ∈ X such that [START_REF] Fitzsimmons | Single-peaked consistency for weak orders is easy[END_REF] y < z and F (x, y) > F (x, z).

Using [START_REF] Fitzsimmons | Single-peaked consistency for weak orders is easy[END_REF] it is easy to see by contradiction that we necessarily have

(x ≾ y or x ≾ z) and (y ≾ x or z ≾ x).
We then have only the following three mutually exclusive cases to consider.

• If y ≺ x ≺ z or y ∼ x ≺ z or y ≺ x ∼ z, then by ( 8) we obtain y < z < x, which violates weak single-peakedness. 8) we obtain x < y < z, which violates weak single-peakedness.

• If z ≺ x ≺ y or z ∼ x ≺ y or z ≺ x ∼ y, then by (
• If x ∼ y ∼ z, then we must have F | [x] 2 ∼ = π 1 | [x] 2 ∼ or F | [x] 2 ∼ = π 2 | [x] 2
∼ , which immediately violates [START_REF] Fitzsimmons | Single-peaked consistency for weak orders is easy[END_REF]. This completes the proof of Proposition 4.4.

From Proposition 4.4 we immediately derive the following characterization of the class of associative, quasitrivial, and order-preserving operations F ∶ X 2 → X, thus generalizing to the noncommutative case the equivalence between assertions (i) and (ii) of Theorem 3.7. We observe that, when X = X n for some integer n ≥ 1, an alternative characterisation of this class has been recently presented in [START_REF] Kiss | Visual characterization of associative quasitrivial nondecreasing functions on finite chains[END_REF]. Theorem 4.5. Let ≤ be a total ordering on X. An F ∶ X 2 → X is associative, quasitrivial, and ≤-preserving iff it is of the form (1) for some weak ordering ≾ on X that is weakly single-peaked w.r.t. ≤.

We now consider the problem of enumerating associative and quasitrivial operations F ∶ X 2 n → X n that are ≤ n -preserving. We will make use of the following two auxiliary lemmas.

Lemma 4.6. Let ≤ be a total ordering on X and let ≾ be a weak ordering on X. If ≾ is weakly single-peaked w.r.t. ≤, then there are no pairwise distinct a, b, c, d Lemma 4.7. Let ≤ be a total ordering on X and let ≾ be a weak ordering on X that is weakly single-peaked w.r.t. ≤. Assume that both min ≤ X and max ≤ X are nonempty and let a = min ≤ X and b = max ≤ X. If max ≾ X ≠ X, then max ≾ X ⊆ {a, b}.

∈ X such that a ≺ b ∼ c ∼ d.
Proof. By Lemma 4.6 the set max ≾ X contains at most two elements. Now suppose that there exists x ∈ (max ≾ X) ∖ {a, b}. Then the set {a, x, b} violates weak single-peakedness of ≾.

Assume that X n is endowed with ≤ n . For any integer n ≥ 0, we denote by u(n) the number of weak orderings ≾ on X n that are weakly single-peaked w.r.t. ≤ n . Also, we denote by u e (n) (resp. u a (n), u ea (n)) the number of weak orderings ≾ on X n that are weakly single-peaked w.r.t. ≤ n and for which X n has exactly one minimal element (resp. exactly one maximal element, exactly one minimal element and exactly one maximal element) for ≾. As a convention, we set u(0) = u e (0) = u a (0) = u ea (0) = 0. Propositions 4.8 and 4.9 below provide explicit formulas for these sequences. The first few values of these sequences are shown in Table 2. 2 It turns out that the sequence (u e (n)) n≥0 consists of the so-called Pell numbers (Sloane's A000129).

Proposition 4.8. The sequence (u(n)) n≥0 satisfies the second order linear recurrence equation

u(n + 2) -2 u(n + 1) -u(n) = 1 , n ≥ 0,
with u(0) = 0 and u(1) = 1, and we have

2 u(n) + 1 = 1 2 (1 + √ 2) n+1 + 1 2 (1 - √ 2) n+1 = ∑ k≥0 ( n+1 2k ) 2 k , n ≥ 0.
Moreover, its GF is given by U (z) = z/(z 3 + z 2 -3z + 1).

Proof. We clearly have u(0) = 0 and u(1) = 1. So let us assume that n ≥ 2. If ≾ is a weak ordering on X n that is weakly single-peaked w.r.t. ≤ n , then by Lemma 4.7 either max ≾ X n = X n , or max ≾ X n = {1}, or max ≾ X n = {n}, or max ≾ X n = {1, n}. In the three latter cases it is clear that the restriction of ≾ to X n ∖ max ≾ X n is weakly singlepeaked w.r.t. the restriction of ≤ n to X n ∖ max ≾ X n . It follows that the number u(n) of weakly single-peaked weak orderings on X n w.r.t. ≤ n satisfies the following second order linear equation

u(n) = 1 + u(n -1) + u(n -1) + u(n -2), n ≥ 2.
The claimed expressions of u(n) and GF of (u(n)) n≥0 follow straightforwardly.

Proposition 4.9. The sequence (u e (n)) n≥0 satisfies the second order linear recurrence equation

u e (n + 2) -2 u e (n + 1) -u e (n) = 0 , n ≥ 0,
with u e (0) = 0 and u e (1) = 1, and we have

u e (n) = √ 2 4 (1 + √ 2) n - √ 2 4 (1 - √ 2) n = ∑ k≥0 ( n 2k+1 ) 2 k , n ≥ 0.
Moreover, its GF is given by U e (z) = -z/(z 2 +2z -1). Furthermore, for any integer n ≥ 1, we have u a (n) = 2u(n -1), u ea (n) = 2u e (n -1), and u a (0) = u ea (0) = 0.

Proof. The formula describing the sequence (u e (n)) n≥0 is obtained by following the same steps as in the proof of Proposition 4.8, except that in this case we always have max ≾ X n ≠ X n . As for the sequence (u a (n)) n≥0 we note that max ≾ X n must be either {1} or {n} and that the restriction of ≾ to X n ∖ max ≾ X n is weakly single-peaked w.r.t. the restriction of ≤ n to X n ∖ max ≾ X n . We proceed similarly for the sequence (u ea (n)) n≥0 . Example 4.10. The u(3) = 8 weak orderings on X 3 that are weakly single-peaked w.r.t. Assume again that X n is endowed with ≤ n . For any integer n ≥ 0, we denote by v(n) the number of associative, quasitrivial, and ≤ n -preserving operations F ∶ X 2 n → X n . Also, we denote by v e (n) (resp. v a (n), v ea (n)) the number of associative, quasitrivial, and ≤ n -preserving operations F ∶ X 2 n → X n that have neutral elements (resp. annihilator elements, both neutral and annihilator elements). As a convention, we set v(0) = v e (0) = v a (0) = v ea (0) = 0. Propositions 4.11 and 4.12 below provide explicit formulas for these sequences. The first few values of these sequences are shown in Table 3.

n u(n) u e (n) u a (n) u ea (n) 0 0 0 0 0 1 1 1 0 0 2 3
≤ 3 are: 1 ≺ 2 ≺ 3, 2 ≺ 1 ≺ 3, 2 ≺ 3 ≺ 1, 3 ≺ 2 ≺ 1, 2 ≺ 1 ∼ 3, 1 ∼ 2 ≺ 3, 2 ∼ 3 ≺ 1,
Proposition 4.11. The sequence (v(n)) n≥0 satisfies the second order linear recurrence equation

v(n + 2) -2 v(n + 1) -2 v(n) = 2
, n ≥ 0, with v(0) = 0 and v(1) = 1, and we have

3 v(n) + 2 = 2+ √ 3 2 (1 + √ 3) n + 2- √ 3 2 (1 - √ 3) n = ∑ k≥0 3 k (2( n 2k ) + 3( n 2k+1 )) , n ≥ 0. Moreover, its GF is given by V (z) = z(z + 1)/(2z 3 -3z + 1). Proof. We clearly have v(0) = 0 and v(1) = 1. So let us assume that n ≥ 2. If F ∶ X 2
n → X n is an associative, quasitrivial, and ≤ n -preserving operation, then by Theorem 4.5 it is of the form (1) for some weak ordering ≾ on X n that is weakly single-peaked w.r.t. ≤ n . By Lemma 4.7, either max ≾ X n = X n or max ≾ X n = {1} or max ≾ X n = {n} or max ≾ X n = {1, n}. In the first case we have to consider the two projections F = π 1 and F = π 2 . In the three latter cases it is clear that the restriction of F to (X n ∖ max ≾ X n ) 2 is associative, quasitrivial, and ≤ ′ n -preserving, where ≤ ′ n is the restriction of ≤ n to X n ∖max ≾ X n . Also, in the latter case we have to consider the two projections 2 . It follows that the number v(n) of associative, quasitrivial, and ≤ n -preserving operations F ∶ X 2 n → X n satisfies the following second order linear equation

F | {1,n} 2 = π 1 | {1,n} 2 and F | {1,n} 2 = π 2 | {1,n}
v(n) = 2 + v(n -1) + v(n -1) + 2v(n -2), n ≥ 2.
The claimed expressions of v(n) and GF of (v(n)) n≥0 follow straightforwardly.

Proposition 4.12. The sequence (v e (n)) n≥0 satisfies the second order linear recurrence equation

v e (n + 2) -2 v e (n + 1) -2v e (n) = 0 , n ≥ 0,
with v e (0) = 0 and v e (1) = 1, and we have

v e (n) = √ 3 6 (1 + √ 3) n - √ 3 6 (1 - √ 3) n = ∑ k≥0 ( n 2k+1 ) 3 k , n ≥ 0.
Moreover, its GF is given by V e (z) = -z/(2z 2 + 2z -1). Furthermore, for any integer

n ≥ 1, we have v a (n) = 2v(n -1), v ea (n) = 2v e (n -1), and v a (0) = v ea (0) = 0.
Proof. The formula describing the sequence (v e (n)) n≥0 is obtained by following the same steps as in the proof of Proposition 4.11, except that in this case we always have max ≾ X n ≠ X n . As for the sequence (v a (n)) n≥0 we note that max ≾ X n must be either {1} or {n} and that the restriction of F to (X n ∖max ≾ X n ) 2 is associative, quasitrivial, and ≤ ′ n -preserving, where ≤ ′ n is the restriction of ≤ n to X n ∖ max ≾ X n . We proceed similarly for the sequence

(v ea (n)) n≥0 . n v(n) v e (n) v a (n) v ea (n) 0 0 0 0 0 1 1 1 0 0 2 4
3. First few values of v(n), v e (n), v a (n), and v ea (n)
Example 4.13. We show in Figure 6 the q(3) = 20 associative and quasitrivial operations on X 3 . Among these operations, q e (3) = 12 have neutral elements and v(3) = 12 are ≤ 3 -preserving.

Remark 5. We observe that the explicit expressions of v(n) and v e (n) as stated in Propositions 4.11 and 4.12 were recently and independently obtained in [START_REF] Kiss | Visual characterization of associative quasitrivial nondecreasing functions on finite chains[END_REF] by means of a totally different approach.

SINGLE-PEAKEDNESS AND WEAK SINGLE-PEAKEDNESS

In this section we further analyze the single-peakedness and weak single-peakedness properties. In particular, we show how these properties can be easily checked graphically.

Define the strict convex hull of x, y ∈ X w.r.t. a total ordering ≤ on X by conv ≤ (x, y) = {z ∈ X ∶ x < z < y}, if x < y, and conv ≤ (x, y) = {z ∈ X ∶ y < z < x}, if y < x. Using this concept we can rewrite the definitions of single-peakedness and weak single-peakedness in a more symmetric way.

Accordingly, a total ordering ⪯ on X is single-peaked w.r.t. a (reference) total ordering ≤ on X iff for any a, b, c ∈ X such that b ∈ conv ≤ (a, c), we have b ≺ a or b ≺ c (see Definition 3.4). In other words, the condition says that from among three pairwise distinct elements of X, the centrist one w.r.t. ≤ is never ranked last by ⪯.

A noteworthy characterization of single-peakedness is that for any total orderings ≤ and ⪯ on X, the operation F = max ⪯ is ≤-preserving iff ⪯ is single-peaked w.r.t. ≤ (cf. Proposition 3.6). Remark 6. It is natural to define the dual version of single-peakedness by saying that from among three pairwise distinct elements of X, the centrist one w.r.t. ≤ is never ranked first by ⪯. By doing so, it is clear that ⪯ is single-peaked w.r.t. ≤ iff the inverse ordering ⪯ -1 (defined by a ⪯ -1 b ⇔ b ⪯ a) is dual single-peaked w.r.t. ≤. For instance, we could replace max ⪯ with min ⪯ and "single-peaked" with "dual single-peaked" in Proposition 3.6. Thus, considering the single-peakedness property or its dual version is simply a matter of convention.

The following proposition provides an alternative characterization of single-peakedness. Recall first that, for any total ordering ≤ on X, a subset C of X is said to be convex w.r.t. ≤ if for any a, b, c ∈ X such that b ∈ conv ≤ (a, c), we have that a, c ∈ C implies b ∈ C. Proposition 5.1 (see [START_REF] Devillet | Characterizations of quasitrivial symmetric nondecreasing associative operations[END_REF]Proposition 3.10]). Let ≤ and ⪯ be total orderings on X. Then ⪯ is single-peaked w.r.t. ≤ iff for every t ∈ X the set {x ∈ X ∶ x ⪯ t} is convex w.r.t. ≤.

The single-peakedness property of a total ordering ⪯ on X w.r.t. some total ordering ≤ can often be easily checked (especially if X is finite) by plotting a function, say f ⪯ , in a rectangular coordinate system in the following way. Represent the reference totally ordered set (X, ≤) on the horizontal axis and the reversed version of the totally ordered set (X, ⪯), that is (X, ⪯ -1 ), on the vertical axis. The function f ⪯ is defined by its graph {(x, x) ∶ x ∈ X}. 3 We then see that the total ordering ⪯ is single-peaked w.r.t. ≤ iff the graph of f ⪯ is "V-free" in the sense that we cannot find three points (i, i), (j, j), (k, k) in V-shape. Equivalently, f ⪯ has only one local maximum.

Example 5.2. Figure 7 gives the functions f ⪯ and f ⪯ ′ corresponding to the total orderings 4 ≺ 3 ≺ 5 ≺ 2 ≺ 1 ≺ 6 (from Remark 3(a)) and 6 ≺ ′ 5 ≺ ′ 2 ≺ ′ 1 ≺ ′ 3 ≺ ′ 4, respectively, on X 6 . We see that ⪯ is single-peaked w.r.t. ≤ 6 since f ⪯ has only one local maximum while ⪯ ′ is not single-peaked w.r.t. ≤ 6 since f ⪯ ′ has two local maxima (also, the points (1, 1), (3, 3), [START_REF] Couceiro | Characterizations of idempotent discrete uninorms[END_REF][START_REF] Couceiro | Characterizations of idempotent discrete uninorms[END_REF] for instance are in V-shape). It is known (see, e.g., [START_REF] Berg | Single-peaked compatible preference profiles: some combinatorial results[END_REF]) that there are exactly 2 n-1 single-peaked total orderings on X n w.r.t. ≤ n . The proof is a simplified version of that of Proposition 4.8 (just observe that either max ⪯ X n = {1} or max ⪯ X n = {n}).

Let us now focus on weak single-peakedness. Recall (cf. Definition 4.3) that a weak ordering ≾ on X is weakly single-peaked w.r.t. a reference total ordering ≤ on X if for any a, b, c ∈ X such that b ∈ conv ≤ (a, c), we have b ≺ a or b ≺ c or a ∼ b ∼ c.

In Proposition 4.4 we saw that for any total ordering ≤ and weak ordering ≾ on X, any operation F ∶ X 2 → X of the form (1) is ≤-preserving iff ≾ is weakly single-peaked w.r.t. ≤. This characterization justifies the definition of weak single-peakedness and shows in particular that the condition a ∼ b ∼ c is necessary in the definition. It is noteworthy that the following equivalence holds

b ≺ a or b ≺ c or a ∼ b ∼ c ⇔ ⎧ ⎪ ⎪ ⎨ ⎪ ⎪ ⎩ a ≺ b ⇒ b ≺ c, c ≺ b ⇒ b ≺ a.
We also have the following alternative characterization of weak single-peakedness. We omit the proof for it is straightforward (by contradiction).

Proposition 5.3. Let ≤ be a total ordering on X and let ≾ be a weak ordering on X. Then ≾ is weakly single-peaked w.r.t. ≤ iff the following conditions hold. Weak single-peakedness of a weak ordering ≾ on X w.r.t. some total ordering ≤ can often be visualized and checked by plotting a function f ≾ in a rectangular coordinate system. Represent the reference totally ordered set (X, ≤) on the horizontal axis and the reversed version of the weakly ordered set (X, ≾) on the vertical axis. 4 Here again the function f ⪯ is defined by its graph {(x, x) ∶ x ∈ X}. Condition (a) of Proposition 5.3 says that the graph of f ≾ is V-free, i.e., we cannot find three points (i, i), (j, j), (k, k) in V-shape. Condition (b) is a little less immediate to interpret graphically. However, Proposition 5.5 below shows how conditions (a) and (b) together can be easily interpreted.

Definition 5.4. Let ≤ be a total ordering on X and let ≾ be a weak ordering on X. We say that a subset P of X of size |P | ≥ 2 is a plateau w.r.t. (≤, ≾) if P is convex w.r.t. ≤ and if there exists x ∈ X such that P ⊆ [x] ∼ . From Proposition 5.5 it follows that conditions (a) and (b) hold iff conditions (a) and (b') hold. As discussed above, condition (a) says that the graph of f ≾ is V-free. Now, condition (b') simply says that the graph of f ≾ is both L-free and reversed L-free, which means that the two patterns shown in Figure 8 (reversed L-shape and L-shape), where each horizontal part is a plateau P , are forbidden. Theorem 5.6. Let ≤ be a total ordering on X and let ≾ be a weak ordering on X. Then ≾ is weakly single-peaked w.r.t. ≤ iff conditions (a) and (b') of Propositions 5.3 and 5.5 hold (i.e., the graph of f ≾ is V-free, L-free, and reversed L-free).

Example 5.7. Let us consider the operation F ∶ X 2 4 → X 4 shown in Figure 9 (left). Using the tests given at the end of Section 2 for instance, we can see that this operation is associative and quasitrivial. It is also ≤ 4 -preserving and such that deg F = (0, 3, 3, 6). Thus, F is of the form (1), where ≾ is the weak ordering on X 4 obtained by ranking the numbers deg F (x), x ∈ X 4 , in nondecreasing order, that is, 2 ≺ 1 ∼ 3 ≺ 4; see Figure 9 (center). By Proposition 4.4 this weak ordering ≾ is weakly single-peaked w.r.t. ≤ 4 . By Theorem 5.6 the graph of f ≾ is V-free, L-free, and reversed L-free; see Figure 9 We can now extend Proposition 5.1 to weak orderings.

Proposition 5.9. Let ≤ be a total ordering on X and let ≾ be a weak ordering on X. Then condition (a) of Proposition 5.3 holds iff for every t ∈ X the set {x ∈ X ∶ x ≾ t} is convex w.r.t. ≤.

CONCLUSION

This paper is rooted in a known characterization of associative and quasitrivial binary operations on an arbitrary set X, which essentially states that each of these operations can be thought of as a maximum with respect to a weak ordering (Theorem 2.1). We established different characterizations of the subclass of associative, quasitrivial, and commutative operations (Theorem 3.3) and different characterizations of the subclass of associative, quasitrivial, commutative, and ≤-preserving operations when X is endowed with a total ordering ≤ (Theorem 3.7). When commutativity is no longer assumed, finding generalizations of these characterizations remains an interesting open question (see below).

When X is an n-element set we also enumerated • all associative and quasitrivial operations with or without neutral and/or annihilator elements (Theorem 4.1 and Proposition 4.2), thus answering an enumeration problem posed in [START_REF] Couceiro | Characterizations of idempotent discrete uninorms[END_REF], • all associative, quasitrivial, and ≤-preserving operations (when X is endowed with a total ordering ≤) with or without neutral and/or annihilator elements (Propositions 4.11 and 4.12). In order to characterize those that are ≤-preserving, we made use of single-peakedness. We proposed a generalization of this concept by introducing weak single-peakedness (Definition 4.3 and Theorem 4.5) and we provided a graphical characterization of the latter (Theorem 5.6). When X is an n-element set, we also enumerated all weak orderings on X that are weakly single-peaked w.r.t. the reference ordering on X (Propositions 4.8 and 4.9). We posted in the Sloane's OEIS [START_REF]The On-Line Encyclopedia of Integer Sequences[END_REF] all the new sequences that arose from our results.

In view of these results, some questions emerge naturally and we now list a few below.

• Generalize Theorems 3.3 and 3.7 by removing commutativity in assertion (i).

• Analyze the asymptotic behavior of the sequence (q(n)) n≥0 (see Remark 4(a)).

• The integer sequences A000129, A002605, A048739, and A163271 were previously introduced in the OEIS to solve enumeration problems not related to weak single-peakedness and quasitrivial semigroups. It would be interesting to establish one-to-one correspondences between those problems and ours. • Find the number of operations F ∶ X 2 n → X n that are associative, quasitrivial, and ≤-preserving for some total ordering ≤ on X. The values for 1 ≤ n ≤ 4 are 1, 4, 20, 130. For instance the operation on X 4 represented in Figure 5 is associative and quasitrivial. However, there is no total ordering ≤ on X 4 for which this operation is ≤-preserving.

APPENDIX: ALTERNATIVE PROOF OF FORMULA (3)

We provide an alternative proof of formula (3) that does not make use of the EGF of the sequence (q(n)) n≥0 .

For any integer n ≥ 0, define s(n) = min{n + 1, 2}. Also, for any integer k ≥ 1, let P k be the vector space of real polynomial functions of k variables, and let T k ∶ P k → R be the linear transformation defined as Similarly, if P (x 1 , . . . , x k ) = (∑ k i=1 x i ) n-k for some integer n ≥ k, then we have

T k (P ) = ∑ I⊆{1,...,k} (-1) |I|+k 2 |I| ∫ [0,1] k ( ∑ i∈I t i ) n-k dt 1 ⋯ dt j = k ∑ i=0 (-1) i+k ( k i ) 2 i { n -k + i i }( n -k + i i ) -1 , ( 10
)
where we have used the formula (see, e.g., [11, p. 202])

∫ [0,1] n ( n ∑ i=1 t i ) k dt 1 ⋯ dt n = { k + n n }( k + n n ) -1
(k ≥ 0, n ≥ 1, integers).

We now use the results above to establish the claimed expression of q(n).

Let us assume that n ≥ 1. Using Theorem 2.1 we can easily see that (see justification in the proof of Theorem 4.1)

q(n) = n ∑ k=1 ∑ n1+⋯+n k =n n1,...,n k ≥1 ( n n 1 , . . . , n k ) k ∏ i=1 ni≥2
2 .

Setting m i = n i -1 for i = 1, . . . , k in the latter formula, we obtain

q(n) = n ∑ k=1 ∑ m1+⋯+m k =n-k m1,...,m k ≥0 n! (m 1 + 1)! ⋯ (m k + 1)! k ∏ i=1 s(m i ) = n ∑ k=1 n! (n -k)! ∑ m1+⋯+m k =n-k m1,...,m k ≥0 (n -k)! m 1 ! ⋯ m k ! k ∏ i=1 s(m i ) m i + 1
Using (9), the linearity of T k , the multinomial theorem, and then [START_REF] Ježek | Quasitrivial and nearly quasitrivial distributive groupoids and semigroups[END_REF], we obtain

q(n) = n ∑ k=1 n! (n -k)! ∑ m1+⋯+m k =n-k m1,...,m k ≥0 ( n -k m 1 , . . . , m k ) T k ( k ∏ i=1 x mi i ) = n ∑ k=1 n! (n -k)! T k ( ∑ m1+⋯+m k =n-k m1,...,m k ≥0 ( n -k m 1 , . . . , m k ) k ∏ i=1 x mi i ) = n ∑ k=1 n! (n -k)! T k (( k ∑ i=1 x i ) n-k ) = n ∑ k=1 k! k ∑ i=0 (-1) i+k 2 i ( n k -i ){ n -k + i i }.
Permuting the sums in the last expression and observing that { n 0 } = 0, we finally obtain

q(n) = n ∑ i=0 (-2) i n ∑ k=i (-1) k ( n k -i ){ n -k + i i }k! ,
from which we immediately derive the claimed expression of q(n).

6 FIGURE 1 .

 61 FIGURE 1. An associative and quasitrivial operation on X 6 (contour plot) Two points (x, y) and (u, v) of X 2 n are said to be F -connected if they have the same F -value, i.e., if F (x, y) = F (u, v). Using this definition, we can state the following four graphical tests (see[START_REF] Couceiro | Characterizations of idempotent discrete uninorms[END_REF]), where F ∶ X 2 n → X n denotes an arbitrary operation and ∆ Xn denotes the set {(x, x) ∶ x ∈ X n }.• F is quasitrivial iff it is idempotent and every point (x, y) ∈ X 2 n ∖ ∆ Xn is Fconnected to either (x, x) or (y, y).• If F is quasitrivial, then e ∈ X is a neutral element of F iff the point (e, e) is not F -connected to another point, i.e., iff deg F (e) = 0.• If F is quasitrivial, then a ∈ X is an annihilator element of F iff the point (a, a)is F -connected to exactly 2n -2 points, i.e., iff deg F (a) = 2n -2. • If F is quasitrivial, then it is associative iff for every rectangle in X 2 n that has only one vertex on ∆ Xn , at least two of the remaining three vertices are F -connected.

3 FIGURE 2 .

 32 FIGURE2. An associative operation on X 3 that is not quasitrivial

FIGURE 3 .

 3 FIGURE 3. The six associative, quasitrivial, and commutative operations on X 3

Figure 4 (FIGURE 4 .

 44 FIGURE 4. An operation F ∶ X 2 6 → X 6 defined by F = max ⪯ , where ⪯ is single-peaked w.r.t. ≤ 6

  Proof. (Necessity) We proceed by contradiction. Suppose that there exist a, b, c ∈ X satisfying a < b < c such that a ≾ b and c ≾ b and ¬(a ∼ b ∼ c). Suppose that a ≺ b and c ∼ b.

Proof.

  We proceed by contradiction. Suppose that there exist pairwise distinct a, b, c, d ∈ X such that a ≺ b ∼ c ∼ d. Assume w.l.o.g. that b < c < d. If b < a < c, then the set {a, c, d} violates weak single-peakedness of ≾. In the three other cases the set {a, b, c} violates weak single-peakedness of ≾.

and 1 ∼

 1 2 ∼ 3. u e (3) = 5 of those have exactly one minimal element and u a (3) = 6 of those have exactly one maximal element. u ea (3) = 4 of those have exactly one minimal element and exactly one maximal element. These four weak orderings correspond to the 2 3-1 = 4 total orderings on X 3 that are single-peaked w.r.t. ≤ 3 .

FIGURE 6 .

 6 FIGURE 6. The 20 associative and quasitrivial operations on X 3

FIGURE 7 .

 7 FIGURE 7. ⪯ is single-peaked (left) while ⪯ ′ is not (right)

  (a) For any a, b, c ∈ X such that b ∈ conv ≤ (a, c), we have b ≾ a or b ≾ c. (b) For any a, b, c ∈ X such that a ≠ c and b ≺ a ∼ c, we have b ∈ conv ≤ (a, c).

Proposition 5 . 5 .

 55 Let ≤ be a total ordering on X and let ≾ be a weak ordering on X. Consider the assertions (a) and (b) of Proposition 5.3 as well as the following one. (b') If P ⊆ X, |P | ≥ 2, is a plateau w.r.t. (≤, ≾), then it is ≾-minimal in the sense that for every a ∈ X satisfying a ≾ P there exists z ∈ P such that z ∼ a. Then we have ((a) and (b')) ⇒ (b) and (b) ⇒ (b'). Proof. Let us prove that (a) and (b') implies (b). Let a, b, c ∈ X such that a ≠ c and b ≺ a ∼ c and suppose that b ∉ conv ≤ (a, c). Assume w.l.o.g. that b < a. If conv ≤ (a, c) is a plateau w.r.t. (≤, ≾), then it cannot be ≾-minimal, which contradicts (b'). Hence conv ≤ (a, c) is not a plateau w.r.t. (≤, ≾), which means that there exists z ∈ conv ≤ (a, c) such that ¬(z ∼ a). By (a) we then have z ≺ a. But then the set {a, b, z} violates condition (a) since the points (b, b), (a, a), (z, z) are in V-shape. Let us now prove that (b) implies (b'). Let P ⊆ X, |P | ≥ 2, be a plateau w.r.t. (≤, ≾) and let a, c ∈ P , a ≠ c. Suppose that P is not ≾-minimal, i.e., there exists b ∈ X such that b ≺ a ∼ c. By (b), we have b ∈ conv ≤ (a, c), which contradicts the fact that P is a plateau w.r.t. (≤, ≾).

FIGURE 8 .

 8 FIGURE 8. The two patterns excluded by condition (b') Summing up, we have proved the following result.

Figures 9 and 10 .

 10 Figures 9 and 10.

  Proof. (Necessity) Let t ∈ X and let a, b, c ∈ X such that a, c ∈ {x ∈ X ∶ x ≾ t} and b ∈ conv ≤ (a, c). By condition (a), we have b ∈ {x ∈ X ∶ x ≾ t}.(Sufficiency) For the sake of a contradiction, suppose that there exist a, b, c∈ X such that b ∈ conv ≤ (a, c) and max ≾ (a, c) ≺ b. Set t 0 = c if a ≺ c, and t 0 = a, otherwise. We then have a, c ∈ {x ∈ X ∶ x ≾ t 0 }. By convexity w.r.t. ≤ we also have b ∈ {x ∈ X ∶ x ≾ t 0 }. Therefore we have max ≾ (a, c) ≺ b ≾ t 0 ,which contradicts the definition of t 0 . Remark 8. The dual version of weak single-peakedness can be defined exactly as we did for single-peakedness (see Remark 6): just replace the condition b ≺ a or b ≺ c or a ∼ ∼ c by a ≺ b or c ≺ b or a ∼ b ∼ c. Here again, considering the weak single-peakedness property or its dual version is simply a matter of convention.

  T k (P ) = I⊆{1,...,k}(-1) |I|+k 2 |I| ∫ [0,1] k P (t 1 , . . . , t k )| ti=0 ∀i∉I dt 1 ⋯ dt k . For instance, if P (x 1 , . . . , x k ) = ∏ k i=1 x mi ifor some integers m 1 , . . . , m k ≥ 0, then we haveT k (P ) = ∑ I⊆{1,...,k} s.t. mi=0 ∀i∉I (-1) |I|+k 2 |I| ∏ we have used the multi-binomial theorem k ∏ i=1 (x i + y i ) = ∑ I⊆{1,...,k} ∏ i∈I x i ∏ i∈{1,...,k}∖I y i .

  • total if ∀x, y: xRy or yRx; • transitive if ∀x, y, z: xRy and yRz implies xRz; • antisymmetric if ∀x, y: xRy and yRx implies x = y.

TABLE 2 .

 2 First few values of u(n), u e (n), u a (n), and u ea (n)

			2	2	2
	3	8	5	6	4
	4	20	12	16	10
	5	49	29	40	24
	6	119	70	98	58
	OEIS A048739 A000129 A293004 A163271

TABLE

  (right).Remark 7. For any integer n ≥ 1, the weak orderings ≾ on X = X n that satisfy conditions (a) and (b') of Propositions 5.3 and 5.5 are known in social choice theory as being singleplateaued w.r.t. ≤ n (see, e.g., [8, Definition 4 and Lemma 17]).5 Thus, by Theorem 5.6 the weak orderings ≾ on X n that are weakly single-peaked w.r.t. ≤ n are also single-plateaued w.r.t. ≤ n and vice versa. Since the graphical representations of these weak orderings need not include plateaus, we will keep our terminology and say that they are weakly singlepeaked w.r.t. ≤ n .

	e e e e e r	r	r f ≾	r
	FIGURE 10. Example 5.8

Thus, when X = Xn the weak ordering ≾ is completely determined by a set of n integers (actually n -1 integers since we have ∑ x∈Xn deg F (x) = n(n -1) whenever F is idempotent).

Note that the sequences A048739 and A163271 are shifted versions of (u(n)) n≥0 and (uea(n)) n≥0 , respectively. More precisely, we have u(n) = A048739(n -1) and uea(n) = A163271(n -1) for every integer n ≥ 1.

When X = Xn for some integer n ≥ 1, the graphical representation of f⪯ is then obtained by joining the points (1, 1), . . . , (n, n) by line segments.

In this representation, two equivalent elements of X have the same position on the vertical axis; see, e.g.,

Both concepts of single-peakedness and single-plateauedness were introduced on finite domains by Black[START_REF] Black | The theory of committees and elections[END_REF].

ACKNOWLEDGMENTS

This research is partly supported by the Internal Research Project R-AGR-0500 of the University of Luxembourg and the Luxembourg National Research Fund R-AGR-3080. The authors thank Meltem Öztürk of Paris-Dauphine University for bringing reference [8] to their attention.