Learning and using relational theories