  In the classical theory of regular languages the concept of recognition by
profinite monoids is an important tool. Beyond regularity, Boolean spaces with
internal monoids (BiMs) were recently proposed as a generalization. On the
other hand, fragments of logic defining regular languages can be studied
inductively via the so-called "Substitution Principle". In this paper we make
the logical underpinnings of this principle explicit and extend it to arbitrary
languages using Stone duality. Subsequently we show how it can be used to
obtain topo-algebraic recognizers for classes of languages defined by a wide
class of first-order logic fragments. This naturally leads to a notion of
semidirect product of BiMs extending the classical such construction for
profinite monoids. Our main result is a generalization of Almeida and Weil's
Decomposition Theorem for semidirect products from the profinite setting to
that of BiMs. This is a crucial step in a program to extend the profinite
methods of regular language theory to the setting of complexity theory.
