The basis of shared intentions in robot and human cognition