A General Similarity Framework for Horn Clause Logic