Sure. If you want full concreteness I can tell you the exact use case of this code.
So the database is a collection of objects, properties for each object, and theorems about the properties. Each theorem is a Horn clause. An example theorem (note the real database is not in Prolog—it’s in JSON, but it is exactly this kind of thing):
trait(X, connected, true) :- trait(X, path_connected, true).
Since every theorem in the database is quantified in exactly this way, the database as it is now doesn’t even make mention of a variable, storing something closer to:
trait(connected, true) :- trait(path_connected, true).
but that’ll have to change one day.
An example property (same as it would be stored in the database):
trait(reals, path_connected, true).
The (real) database has over 200 objects and over 200 properties, so instead of storing every single property for every single object, it deduces them from the theorems it has. The key is that it can provide you a deduction upon request. You can also query what objects have a given property, and what properties a given object has (these don’t require derivations).
You also can query trait(obj_atom, prop_atom, V) and get the truth value of a property if there’s any info, including a derivation if you want. All of this is quite fast on the current implementation, which I did not make.
The exact query need not be trait/3 or anything in particular.
There’s been talk of increasing the database’s expressive power in terms of what theorems it can produce (e.g. having two quantified variables) and I thought Prolog might work well for this, since the original database literally is already a database of Horn clauses. So I wanted to try and, for fun, recreate the database and its deduction feature in Prolog. That’s the very concrete thing I am coding. My existing solution that I described does seem to work, but incredibly slowly (it takes forever and a day to finally realize you’ve walked through a cycle, though it does look like the code is not recursing infinitely, and recursion depth limits do work eventually).