A Mathematical Framework For Transformer Circuits