I'm trying to prove the following :
Let S be the free semi-group on the alphabet $ A$ and let T be an arbitrary semi-group.
Assume that $ g : A \rightarrow\ T $ is any mapping.
Prove that there is a unique homomorphism $ h : S \rightarrow\ T$ with the property that $ h(a) = g(a)$ for every a $ \in A$ .
I know elements of S are functions $f$ with finite domain from natural numbers , and range $\subseteq A$ .
so I need a homomorphism that takes every function in S to an element in T .
My idea is $h(f)$ = $ g\circ f $ . But this seems to be wrong ,since $g\circ f$ is a function , and T is an arbitrary semi group . so maybe I need to modify my function to $h(f)$ = $ g\circ f(i) $ for some i $\in dom(f)$ , but what i to choose ??
More informally, elements of the free semigroup on $A$ have the form $a_1 a_2 \cdots a_n$, where each $a_i \in A$.
A homomorphism $h:S \rightarrow T$ satisying $h(a) = g(a)$ for all $a \in A$ must also satisfy $$h(a_1 a_2 \cdots a_n) = h(a_1)h(a_2)\cdots h(a_n) = g(a_1)g(a_2)\cdots g(a_n).$$
The formalism you're using would regard the product $a_1 a_2 \cdots a_n$ as a function $f:\{1,\ldots,n\} \rightarrow A$. (This is a common way of formalizing subscripts.)
Your suggested $g(f)(i)$ for some $i \in \text{dom}(f)$ would only refer to a single factor $g(a_i)$. Based on the above discussion, what is required is that $h$ map $f$ to a product over its domain:
$$h(f) = \prod_{i \in \text{dom}(f)} (g \circ f)(i),$$
where the product is in $T$ and is taken in increasing order of the subscripts. With the proper correspondences, the slicker answer $g \circ f$ would work.