Synthesis via active learning: theory and applications