Learning Formal Specifications from Membership and Preference Queries