Fix writeln statement generation
Semantic checks for negation, remove unnecessary semantic records