Machine Grading of Charts Based on Formal Specifications