A Logic Programming Framework for Learning by Imitation