This idea about elaborating relations under constraints is really interesting. See Thorsten Altenkirch on NaÏve Type Theory and An Interesting and Useful Duality and Condensing Programs . See miniKanren, live and untagged: quine generation via relational interpreters (programming pearl) by William E. Byrd, Eric Holk and Daniel P. Friedman and https://minikanren.org/ for more on Micro Kanren ( 21:00 ). See also What is Formal Logic? and Nada Amin - Metacircular Interpretation ad infinitum . Subscribe to Strange Loop . See A small embedding of logic programming with a simple complete search by Jason Hemann, Daniel P. Friedman, William E. Byrd and Matthew Might and Visualizing miniKanren Search with a Fine-Grained Small-Step Semantics by Brysen Pfingsten and Jason Hemann where they describe a web interface to a semantic model which lets users interactively view the reduction steps. Here are some rela...