There is another great story by Lem called Golem XIV about an AI, constructed by the US Military. It is tasked with destroying enemies of the US, to which it says something to the effect of "Why? That makes no sense" and proceeds to give a philosophical lecture, then sort of disappears. Lem was really good at breaking down common scifi tropes and presenting them from a point of view it hasn't been considered, sometimes surprisingly obvious.