Automatic logical inference