calculation of the state transition matrix of languages