A Formal Approach to Molecular Docking