Very nice!
In the Scryer Prolog discussions, Alex has shared a few ideas and considerations for possible improvements to the Prolog code, including the use of metaprogramming to automatically generate more general relations:
https://github.com/mthom/scryer-prolog/discussions/3221
I hope for an interesting followup article!
Another very interesting Prolog program by Alex is factgraph.pl:
https://github.com/alexpetros/factgraph.pl
It's a Prolog implementation of the IRS Fact Graph, an application of Law as Code.