A Mathematical Foundation For Locality