Algorithm for computing the collection of all string homomorphisms $f$ such that $f(s) = t$ for fixed strings $s,t$

29 Views Asked by At

I'm coding on a website in Django so all my code will be implemetned in Python.

Anyway, I'm interested in the most efficient algorithm to compute the following problem.

Given input strings $s = abcdAbcdBCe$ and $t = xyz\dots \alpha$ where capital leters are variable symbols (!) and lower case letters are any characters in the string's alphabet; enumerate the collection of all string homomorphisms $f : \Sigma^* \to \Sigma^*$ such that $f(s) = t$. If there are none, then return an empty set.

Attempt.

(TODO: I'm writing this now in Python code)

EDIT: $AB = A\circ B$ always in my application, or in other words juxtaposition actually is not possible internally (of two variables). I noticed that this usually greatly simplifies the possible number of string homs to enumerate.