Type checking logical expressions