Add implementation as well as tests for logical algorithms.