It is pretty basic code without anything tricky so really doesn’t need comments. Don’t get me wrong thinking that I am against comments, I am all for them when needed.
Instead it would be better if you asked about what you don’t understand, then I or others can answer those questions individually. But before asking look in Learn Prolog Now! or one of the free books or classic books. Also if you are serious about learning Prolog then get one or more of the classic books.