The basis of shared intentions in human and robot cognition