The Mathematics of Syntactic Structure