Gl-learning: an optimized framework for grammatical inference