In one of my answers I elaborated on the way we do language-tailored plagiarism checks on student submissions:
The general idea is to strip comments, whitespace, variable and function names, literals, and thus only keep the general structure of a program, i.e. parentheses, curly braces, semicolons, etc. (for C-like, that is). Then compare this 'hash' for all hand-ins, and when you find a match manually check if the programs look alike. For example, the hash of the program below would be something like
#<>(,*){(;;--){("",);}}
:#include <stdio.h> void repeat(int n, char *word) { for (; n; n--) { printf("%s\n", word); } }
While this model has proven successful in the past, there are a few obvious ways to escape these plagiarism checks:
- Moving functions around
- Changing parameter order
- Omitting / using
{
and}
around single-line blocks
Fortunately, these are not the things most students think about (usually, they rename functions and variables / include comments). However, I am interested in improving this model or using something that already exists which would tackle these issues above as well - not only because I want to be able to detect plagiarism but also because I find this an interesting problem.
In particular, I am thinking about a system that would actually parse the programs and compare the abstract syntax trees for similarities. Does any such system exist?