Lagrange theorem for finite algebraic structures. Let $S$ be a finite semigroupoid and let $a\in S$. The minimum of
$$\{n\in \Bbb N \mid a^{n+1}=a \}$$
, if it exists, is called the order of $a$ and is denoted by $o(a)$.
Which conditions on $S$, guarantee 
$$o(a)\mid |S|$$
To be more specific, is it true if $S$ is a


*

*semigroup

*category

*monoid

*groupoid
 A: Lagrange's theorem is very much specific to groups. Here are some counterexamples.


*

*$S$ a monoid: consider the monoid $\{ 1, a, a^2 \}$ where $a^3 = a$. It has $3$ elements, but the order of $a$ is $2$. Since monoids are both semigroups and categories, this also takes care of those cases.

*$S$ a groupoid: consider the disjoint union of a group of order $1$ and a group of order $2$. As above, it has $3$ elements, but there is an element of order $2$.


In the comments you ask about the case that $S$ is a cancellative semigroup. Since you ask whether a number can divide $|S|$, implicit here is the assumption that $S$ is finite.
Proposition: A finite cancellative semigroup is a group.
Proof. Let $S$ be such a semigroup. Then for every $s \in S$, the function
$$x \ni S \mapsto sx \in S$$
is injective by assumption. Since $S$ is finite, it must also be bijective and have order dividing $|S|!$. It follows that some power of $s$ acts as a left identity. Similarly, some power of $s$ acts as a right identity. It follows that some power of $s$ acts as an identity, call it $e$. Then for every $s$ there exists $s^{-1}$ such that $s s^{-1} = e$, so every element has a right inverse, and similarly every element has a left inverse, and these must agree. $\Box$
