Handle ghost variables in pattern matching