Text this: A mathematical formulation of intelligent agents and their activities