A syntactic approach to robot learning of human tasks from demonstrations