Looks like it&#x27;s more like Datalog than full Prolog. [0]  You are probably using something similar to what is called the &quot;semi-naive&quot; evaluation strategy (which despite the disparaging-sounding name is actually pretty good).<p>[0] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Datalog" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Datalog</a>