Gl-learning: An optimized framework for grammatical inference