Logic inference using backward chaining