Higher Order Prolog with Extensional Semantics