Hi. I was wondering : how can I sort multiple results coming out of run*
? The idea is to sort them using core.logic itself by expressing preferences rules ? In particular, I’m wondering how I can express an ‘arbitrary’ preference order such as : prefer ?a over ?b. I’ve already used systems that worked this way : they checked for acyclicity so as to avoid contradiction in the preference statements (which were just binary relations).
I think i really am just looking for a way to make a topological sort. Any idea ?
minikanren, on which core.logic is based, does this interleaving of goals to make it so non-convergent goals don't continue to not converge infinitely while a convergent goal never gets a chance to run
I think that would make it difficult to impossible to get ordering without some deeper modifications
https://scholarworks.iu.edu/dspace/bitstream/handle/2022/8777/Byrd_indiana_0093A_10344.pdf you can search for "interleaving" to read more about it, they mention it a lot, are very proud of it, and contrast it with prolog
without the interleaving, given a conde, the first branch would be searched exhaustively, then the next, etc
Indeed this seems non-trivial, I’m probably better off doing the sort using functional programming rather than relational programming. Actually, I’m currently investigating minikanren in order to express business rules. I haven’t found much resources about this and I must confess I am somehow disappointed – but maybe this is because I haven’t employed many rules in my experiments so far. I’d be interested in reading stuffs (blogs, books, whatever) about solving business related problems with minikanren. So far, most of the use of minikanren I saw concerned small problems that had some kind of mathematical purity at their heart (the sudoku solver for instance), whereas I’m trying to determine if it could be of any use in cases where there a many rules such as in a business related environment (for instance, billing rules).
minikanren isn't a rules engine
with a billing system in minikanren, you could ask questions like "is it possible to get a bill with the properties x y and z", which is interesting and in many circumstances useful, but I think most businesses are concerned with if this then that style rules, which you can do in a relational language, but you'll be able to do better using a rules engine
I think this split is what is referred to as backwards chaining (what relational languages do) and forward chaining (what rules engines do)
the split isn't entirely black and white, mature rules engines and relational environments tend to support both