Theoretical foundations for the responsibility of autonomous agents