Logic and Functional Programming by Retractions