# Is unification over regular expression equations doable?

By way of example, suppose I know that $$X + a = b + Y$$ where $$X$$ and $$Y$$ are variables standing for regular expressions, then $$(X, Y) = (b, a)$$ is a solution to this set of equations.

Generalizing over all such equations, is there a computable (decidable) procedure for calculating the regular expressions which the variables must stand for in order for the equation to be solvable? Is there some kind of uniqueness, e.g. of minimal solutions?

In case the alphabet size matters: you can represent $$\{1, \ldots, n\}$$ in unary using just two symbols, so I assume the answer for $$k$$- and $$m$$-symbol alphabets are the same when $$k \geq 2 \land m \geq 2$$, in which case I care primarily for alphabets of size $$\geq 2$$—the reason I stress the word "assume" is that I know some properties of regular languages don't hold for regular expression equations (when suitably translated).

The application I have in mind is miniKanren-style logic programming.

Since families of sets closed under union form a semilattice, and the family of regular languages is one such closed family, programming with regular languages seems straightforward. For example, let each logic variable $$V$$ represent some indeterminate language $$L$$. For each $$V$$ store a pair of bounds $$(sub, disj)$$ expressing the knowledge $$sub \subseteq L \land (L \cap disj) = \emptyset$$, i.e. store two sets of strings for which the membership-ness is known. Grow them in the variable unification part and fail when $$sub \cap disj \not= \emptyset$$.

It would be nice to add logic over regular expressions and not just regular languages. No obvious approach occurs to me, and I suspect it's a whole other ballgame.

• I'm not talking about syntactic (expression-tree recursive) equality, i.e. I'm happy with $(X, Y) = (b, a)$ as a solution to your example. I don't quite understand the $X = Y = \{a, b\}^*$ part. My terms are standard regexps $(0, 1, a ∈ Σ, +, ·,\ ^*)$ with variables. An equation is satisfied if it holds whenever (variable-free) regular expressions variables are substituted for the variables (over all substitutions), and "holds" means the two sides describe the same language—i.e. (I think) I want e.g. $\{(X, Y) \mid a + b = X + Y\}$, suitably generalized. Does that answer your questions? Nov 10 '19 at 21:59