A Bi-Directional Refinement Algorithm for the Calculus of (Co)Inductive Constructions (Logical Methods in Computer Science, 2012)