Top-down synthesis of divide-and-conquer algorithms